Check Browser Close Event
-
Good Morning, Is it possible to fire an event when user closes the browser window in javascript or any other language? Please help. I have user a login system in my project which is being made in asp.net 2.0. I want that when user closes the browser window it should logout autmatically. If anyone of you knows about it please guide me. Thanks. waiting for reply. Bye. Abubakar
-
Good Morning, Is it possible to fire an event when user closes the browser window in javascript or any other language? Please help. I have user a login system in my project which is being made in asp.net 2.0. I want that when user closes the browser window it should logout autmatically. If anyone of you knows about it please guide me. Thanks. waiting for reply. Bye. Abubakar
-
I saw an good article the other day on handing browser close events on the server side http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide[^] Hope it helps
Thanks for reply. I don't think it could be solution becaue "onunload" function will be called every time even user moves to another page by clicking a link then user will be logout which is not right. what do u think?
-
I saw an good article the other day on handing browser close events on the server side http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide[^] Hope it helps
hi there ca u provide the link other then ajax thanQ
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
-
Good Morning, Is it possible to fire an event when user closes the browser window in javascript or any other language? Please help. I have user a login system in my project which is being made in asp.net 2.0. I want that when user closes the browser window it should logout autmatically. If anyone of you knows about it please guide me. Thanks. waiting for reply. Bye. Abubakar
Abubakarsb wrote:
I want that when user closes the browser window it should logout autmatically.
Session will have some timeout specified. It will end after that time. So no need to end it explicitly when user closes browser. And I don't think that doing this using javascript will be a good solution, because if javascript is disabled on user browser, your script won't work. Are you updating any value in database when user logs out ?
-
Abubakarsb wrote:
I want that when user closes the browser window it should logout autmatically.
Session will have some timeout specified. It will end after that time. So no need to end it explicitly when user closes browser. And I don't think that doing this using javascript will be a good solution, because if javascript is disabled on user browser, your script won't work. Are you updating any value in database when user logs out ?
N a v a n e e t h wrote:
Are you updating any value in database when user logs out ?
Check out this article if you are depending on Session_OnEnd for your logic: http://www.eggheadcafe.com/articles/20030418.asp[^]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
N a v a n e e t h wrote:
Are you updating any value in database when user logs out ?
Check out this article if you are depending on Session_OnEnd for your logic: http://www.eggheadcafe.com/articles/20030418.asp[^]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
Vasudevan Deepak Kumar wrote:
Check out this article if you are depending on Session_OnEnd for your logic:
Yes read that more than 3 times, all from your message only. But I didn't had any problem with firing session_end event. It works perfectly for me. I feel in article they are concentrating on webfarms, and this thread starter has not told that he is using a webfarm. He may be using InProc, and for that session_end will easy and optimum ? What do you say ?
-
Abubakarsb wrote:
I want that when user closes the browser window it should logout autmatically.
Session will have some timeout specified. It will end after that time. So no need to end it explicitly when user closes browser. And I don't think that doing this using javascript will be a good solution, because if javascript is disabled on user browser, your script won't work. Are you updating any value in database when user logs out ?
No, I am not updating any value. I am just logging out of user from the system. The problem is sometimes when I close the browser it loged out user but when I try to relogin again with same username it says "User is currently Login"
-
No, I am not updating any value. I am just logging out of user from the system. The problem is sometimes when I close the browser it loged out user but when I try to relogin again with same username it says "User is currently Login"
Abubakarsb wrote:
it says "User is currently Login"
How you are checking this ? That's what I asked are you storing any values to identify whether user is online ?
-
Abubakarsb wrote:
it says "User is currently Login"
How you are checking this ? That's what I asked are you storing any values to identify whether user is online ?
Sorry guys! I was really busy with other parts of my project. Regarding to your question "How you are checking this ? That's what I asked are you storing any values to identify whether user is online ? " The thing is I am new in Visual Studio 2005 (Asp.net 2.0) and a developer already made this, I am just updating it. I don't have any idea how new login system works in VS2005. I really don't know how he is storing or checking that whether user is login or not? He made a commonMaster page and I have found a check please check code below, may be it helps you to understand my problem, if you still need more please don't hasitate. I want to fix this soon. Thanks. if (Properties.IsLoggedIn) { string cookieName = FormsAuthentication.FormsCookieName; HttpCookie authCookie = Context.Request.Cookies[cookieName]; FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); MembershipUser mu = Membership.GetUser(); Properties.EndUserGUID = mu.ProviderUserKey.ToString().ToUpper(); DateTime expiration = authTicket.Expiration.AddSeconds(-90); if (expiration < DateTime.Now) { mu.LastLoginDate = DateTime.Now; Membership.UpdateUser(mu); FormsAuthentication.SetAuthCookie(Context.User.Identity.Name, true, "/"); } }