简体   繁体   English

监控用户在页面上的天数

[英]monitor days the user is on the page

I want to track that the user has played the game on my website for 15 minutes per day and for continuous 10 days if he misses one day then his needs to again start from day 1 using JavaScript and PHP.我想跟踪用户每天在我的网站上玩游戏的时间为 15 分钟,如果他错过了一天,那么他需要从第一天开始使用 JavaScript 和 PHP 重新开始玩游戏连续 10 天。

I am getting stuck in the idea that how we can track the 15 minutes a day and 10 days for a specific user.我陷入了一个想法,即我们如何可以跟踪特定用户每天 15 分钟和 10 天的时间。

As @arkascha mentioned, tracking user involves using sessions and saving data to permanent storage (you can save into file for first time, but learn DB management - PHP is closely tied with this one)正如@arkascha 提到的,跟踪用户涉及使用会话并将数据保存到永久存储(您可以第一次保存到文件中,但学习数据库管理 - PHP 与此密切相关)

But before that you need to ask YOURSELF with few questions但在此之前你需要问自己几个问题

  1. Why do need to check data about users on your site?为什么需要检查您网站上的用户数据? Remember that most of time users don't spend on web page, maybe it's better to check their requests to your site?请记住,大多数时间用户不会花在网页上,也许检查他们对您网站的请求会更好?
  2. What type of network environment you're using.您使用的网络环境类型。 Is your website is opened for entire world (eg Internet) or you're located in small network with network access rules?您的网站是面向全世界开放的(例如 Internet)还是位于具有网络访问规则的小型网络中?
  3. How you should identify your users?你应该如何识别你的用户? By IP or some kind of name?通过 IP 或某种名称? Answering 3rd question can be done via requesting phpinfo() function and checking following variables $_SERVER['USERNAME'], $_SERVER['REMOTE_USER'], $_SERVER['REMOTE_HOST'], $_SERVER['REMOTE_ADDR']回答第三个问题可以通过请求phpinfo()函数并检查以下变量$_SERVER['USERNAME'], $_SERVER['REMOTE_USER'], $_SERVER['REMOTE_HOST'], $_SERVER['REMOTE_ADDR']

  4. Learn sessions (start from manual http://php.net/manual/en/function.session-start.php )学习课程(从手册http://php.net/manual/en/function.session-start.php开始)

And remember - you should ask questions about particular problems (for example, "Session variables are not storing on PHP 7.x, Ubuntu XX, Apache 2.4.x"), NOT general ones (please write the code for me)请记住 - 您应该询问有关特定问题的问题(例如,“会话变量未存储在 PHP 7.x、Ubuntu XX、Apache 2.4.x 上”),而不是一般问题(请为我编写代码)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM