how do i notify users when their sessions has timed out - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: how do i notify users when their sessions has timed out (/showthread.php?tid=68560) |
how do i notify users when their sessions has timed out - java - 07-27-2017 I am new to codeigniter and i am currently working on project , I would like to notify users that their session has expired with a pop message before a redirect to the login page. Can anyone help me out please? RE: how do i notify users when their sessions has timed out - skunkbad - 07-27-2017 Javascript. Check time against session expiration every X seconds. Use modal to confirm user wants to extend session when they need to. Send request to server if they do, which should automagically keep the session ball rolling. RE: how do i notify users when their sessions has timed out - PaulD - 07-28-2017 OOoooh. That is a really good idea. Was just looking at how to do this myself and was stuck. But that is a really cool plan. Not sure how to do that in js but it is a good sounding approach. Thanks. Paul. RE: how do i notify users when their sessions has timed out - Kaosweaver - 07-28-2017 (07-28-2017, 10:45 AM)PaulD Wrote: OOoooh. That is a really good idea. Was just looking at how to do this myself and was stuck. But that is a really cool plan. Not sure how to do that in js but it is a good sounding approach. Thanks. jQuery AJAX POST to a controller, return JSON encoded reply, have the JS pop a modal at the right time for the user to maintain the session (with a count down so the user has a sense of "I should take care of this"). I do jQuery AJAX calls all of the time, it isn't that difficult, pretty sure you'll get it RE: how do i notify users when their sessions has timed out - skunkbad - 07-28-2017 (07-28-2017, 10:45 AM)PaulD Wrote: OOoooh. That is a really good idea. Was just looking at how to do this myself and was stuck. But that is a really cool plan. Not sure how to do that in js but it is a good sounding approach. Thanks. I've never actually done this. I was just thinking as I was typing. I think you could do the looping with setInterval, like this: https://stackoverflow.com/a/1542294 Get the epoch time in javascript: https://stackoverflow.com/a/9456144/667090 Put the epoch time of session expiration in a hidden input so javascript can see it easily.... If expiration is less than X seconds, add a class or attribute to hidden input, so that the loop quits checking the time, then pop up the modal .... RE: how do i notify users when their sessions has timed out - skunkbad - 07-28-2017 (07-28-2017, 11:37 AM)Kaosweaver Wrote:(07-28-2017, 10:45 AM)PaulD Wrote: OOoooh. That is a really good idea. Was just looking at how to do this myself and was stuck. But that is a really cool plan. Not sure how to do that in js but it is a good sounding approach. Thanks. This wouldn't work because the ajax post to the controller would automatically extend the session, unless you're not autoloading the session, which I think is rare for people who use sessions. |