AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Jquery idle timer4/3/2023 ![]() The other way you could handle this is to maintain a "ping" process that routinely pings the server (via setInterval(), for example) to keep the session alive, and uses a separate timeout (maybe something like the "Authentication timeout" that ASP.NET uses) to keep track of when the "idle" user should be logged out. Perhaps you could handle this differently: use cookies, single sign-on or similar techniques to pre-authenticate or automatically authenticate requests so that the user's session can safely die and be restarted without the user having to manually login. If the user is scrolling you can use javascript to listen for scroll events (via onscroll, for example), but this will not be 100% reliable because (1) depends on javascript, and (2) doesn't work if you are viewing a short article or using a tall/large format monitor (like the ones you can rotate 90 degrees, for example). If the user is not making requests, and is not moving the mouse or keyboard or touching the device, etc., then from the app's point of view the user is "idle" even if their eyeballs are not. How can I solve this problem? is there a better plugin to does the trick? if there something I missed in this plugin that will solve my problem? Then after 20 minutes the user refresh the page, then the user will be logged out since he/she have not sent a new request to the PHP server for over the 900 seconds limit. He/she will be scrolling, they are not really idle "from JavaScript perspective" but from a PHP perspective the use is idle. A user is reading a super long article on the same page. ![]() Here is the senario where this script does not help me: lets say my PHP sessions has a limit on 15 minutes/ 900 seconds. The issue with this plugin is that it checks if the user is idle using JavaScript (if the keyboard/mouse) are being used. I did find a nice plugin that will somewhat does the Job jquery-idle-timeout If the user did not click anything or clicked on "Log out" then the session ends and the user is redirected to the login page. If the use clicks "Keep working" then the jQuery script will send PHP AJAX request to renew the session $_SESSION = time()+900. ![]() What I am looking to do is display a dialog message 2 minutes before the PHP session expire and check if the user is still on the page or not. Within this class I have a method that returns how many seconds remaining before the session expires.Īlso, Evey time the user refresh the page or open a new page (new request to the server) the idle time counter starts over $_SESSION = time()+900 ![]()
0 Comments
Read More
Leave a Reply. |