When will session be expired?
I set session timeout to be 5 minutes in web.xml. And once session expired sessionDestroyed() will be executed.
But I want session to be alive as long as browser window is still there. So in each JSP page there is a piece of JavaScript code that visits an image on the server every开发者_Python百科 100 seconds. Basic idea regarding this part can be found at http://www.intelliproject.net/articles/showArticle/index/js_session_expired
However, the sessionDestroyed() will still be executed in 5 minutes. Here is my question, why sessionTimeout event is triggered even though I keep visiting it every 100 seconds?
Using firebug, open the net tab and watch for the javascript request. You should be receiving HTTP 200
for each image GET, and each url should have random numbers appended to the end. You should probably just use a timestamp, rather than random numbers, as random numbers might eventually repeat and log the user out.
Do you have an example page where this is happening?
- make sure your js call executes - there are no js errors (see error console), and that 200 is returned
- Do not use random parameter at the end of the image - this is not guaranteed to bypass the cache. Istead set the Expires / Cache-Control headers of the accessed resource
- Don't use an image, use an empty text (jsp) file. You can also manually set the headers there.
精彩评论