You need to check on the client side if the session has expired. The easiest way is to simply start the countdown (before the timeout), using javascript when the page loads. After this period, send the user to the login page. Or maybe itโs better: just tell the user that the session has expired, because maybe he wouldnโt be too happy if you just sent it somewhere. Although my online banking software does just that, but for security reasons, of course.
Here is a very simple example: http://jsfiddle.net/39Sj6/1/
function sessionHasExpired(){ if(confirm("Your session has expired. Do you want to go to the login page")){ window.location = "http://google.com/?q=login"; } } var sessionTimeInMilliseconds = 1000*60*5;
(In jsfiddle, you will not be redirected to google, as this is forbidden by jsfiddle, but in principle it will work)
source share