Welcome Guest, Not a member yet? Register   Sign In
how do i notify users when their sessions has timed out
#1

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?
Reply
#2

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.
Reply
#3

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.
Reply
#4

(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.

Paul.

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 Smile
Reply
#5

(This post was last modified: 07-28-2017, 03:54 PM by skunkbad.)

(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.

Paul.

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 ....
Reply
#6

(This post was last modified: 07-28-2017, 03:50 PM by skunkbad.)

(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.

Paul.

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 Smile

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB