Click here to Skip to main content
15,885,885 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi :)

I want my session to end when i close the browser ... I know we can use session.Abondon() but in which event should i put...

Do you have another option?

And on session timeout if i want to show a message to the user saying "Session Expired" o smthing ... How do i do tat?

:) Thnx
Posted
Comments
Ankur\m/ 16-Dec-10 7:11am    
This question has been asked so many times here, and in other forums. Google/Bing are your friend. Search!

This code will work only in IE.
Try this,
javascript:
C#
function fnOnunLoad() {
if (window.event.clientX < 0 || window.event.clientY < 0) {
   document.getElementById("ctl00_lnkLogout").click();
 }
 }

Then in body tag use this,
<body onunload="fnOnunLoad()">

If you written the session.Abondon() code in logout button click, then that javascript will call this logout click function.
 
Share this answer
 
Comments
Manfred Rudolf Bihy 16-Dec-10 7:01am    
One question Toniyo, wont this logout the user when he's changing pages, or does the bit with clientX and clientY being smaller than zero do the trick?
Is it cross browser compatible?
Hiren solanki 16-Dec-10 7:07am    
Good answer tonyo.
Toniyo Jackson 16-Dec-10 7:09am    
Thank you Hiren
There is one more that you can follow. Have a look to following link

Click here
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900