If a user closes the browser abruptly, session will not be destroyed, it will be still active, session is destroyed after the session time out period is expired..
How can you do it with HTTP protocol? With HTTP, only client can initiate the conversation. If you close the browser, then how do you notify it to server? You can do it with JS/AJAX. Try it.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Ramasubramaniam Rathinasubbu
Ranch Hand
Joined: Jun 09, 2010
Posts: 42
posted
0
How can i get whether the client session is expired or not
Abimaran Kugathasan wrote:How can you do it with HTTP protocol? With HTTP, only client can initiate the conversation. If you close the browser, then how do you notify it to server? You can do it with JS/AJAX. Try it.
Not reliably, nor will it handle browser or machine crashes, nor if the user has JavaScript turned off.
Onbeforeunload or something like that is your only hope, and it doesn't cover all circumstances, and covers *none* of them if JavaScript is turned off.
hi abimaran,
I think david is right, you need to call Onbeforeunload to invalidate the session. but in Onbeforeunload make a Ajax call and call a servlet which will invalidate the existing session this is the only way you can invalidate the session on browser close.
[Vipassana] - It is seeing the reality as it is, And not as you want it to be.!!!
SCJP1.5.