开发者

PHP, javascript, cronjobs - Ajax test if user is online fail

Good day to all. I have a strange problem.

I created a PHP script that inserts into a database the unix timestamp when it was accessed (PHP - time() function).

开发者_运维知识库

When a user is viewing a certain page a ajax request is send at every 57 seconds to the mentioned script.

I also created a cronjob that runs a PHP script that checks if the difference between the current time and the time logged in database for a certain user is higher than 2 minutes. The cron is set to run the script every 2 minutes, if is higher I mark the user as idle.

Now the problem is: Even though both seem to work fine, sometimes (seems very random to me) a user that is viewing the page is marked as idle. I can't find any explanation... perhaps any1 have an idea?

Unfortunately I can't provide an online version... but I answer any questions in max 10 mins.

The ajax script:

PHP, javascript, cronjobs - Ajax test if user is online fail

The insert script:

PHP, javascript, cronjobs - Ajax test if user is online fail

The cron:

PHP, javascript, cronjobs - Ajax test if user is online fail

Thank you for help.


Does your user hava Javascript enabled? Is your server getting the AJAX requests from that specific user?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜