locked
Session_end event RRS feed

  • Question

  • User-1773948845 posted

    It is known point that Session_start event is fired when the browser starts rendering the output. I would like to know  if there is any chance that how does the browser knows to fire the "Session_start" event.  If the browser can "think" that it has to fire the "Session_start" event at the time of browser starting the page then the browser should be able to "think" that it has to fire the "Session_end" event at the time of closing the browser. But it does not happen like that ? Any guess or analysis on this question.

     

    Monday, June 23, 2008 2:13 AM

Answers

  • User-833084849 posted

    Session not start in browser because session only managed by IIS so browser is a gateway. So through gateway you can start session and you can also end session but auto end facility is not with browser. if you want to embed it you should create your own web browser.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2008 5:33 AM
  • User1174340047 posted

    hi, Ganesh@Nilgris.

    i think your confuse derives from your misunderstanding of how HTTP works. A broswer and a web server communicate with each other throught HTTP, the broswer can send http request to the web server whenever it wishes to, but the web server can send http response to the broswer only when it receives a http request from the broswer, otherwise the web server has no way to send http response because the web server just has no idea which broswer to send the response. That's to say, the broswer and web server have a active-passive relationship.

    If the browser can "think" that it has to fire the "Session_start" event at the time of browser starting the page

    whether to fire the session_start event is not determined by the broswer, it is determined by the web server (actuallythe asp.net runtime). The Asp.net runtime checks whether the request contains the "ASP.NET_SessionId" cookie. if it doesn't contain, asp.net start a new session for the request.

    the browser should be able to "think" that it has to fire the "Session_end" event at the time of closing the browser

    The same logic as session_start event. According to the timeout property of the session, asp.net determines when to remove a session, all this is finished without the participancy of the broswer. Additionally, the web server has no way to notify this "session time out" to the broswer.

     I think this should be helpful to you. Let me know if you still are confused.Thank you.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 26, 2008 11:24 AM

All replies

  • User-833084849 posted

     Yes you are right Session_Start fires on page request but session_end not.

    When you close browser session_end not fires because its fires on timeout=20,,etc if you want to call it you must code your self.

    read some links .

    http://www.velocityreviews.com/forums/t95767-how-to-end-a-session-when-the-user-closes-the-browser.html 

    http://www.theserverside.net/discussions/thread.tss?thread_id=28826 

    http://www.eggheadcafe.com/community/aspnet/17/10030379/session-time-out.aspx 

    Monday, June 23, 2008 2:52 AM
  • User-1773948845 posted

    I can understand about the "timeout" and also "abandon". My possible thinking is why the browser is not intelligent enough to call a "session_end" event when the browser closes? When the browser is intelligent enough to call the "session_start" event the vice versa should also be same.

    May be in future browsers people would found out suitable solutions.

     

     

    Monday, June 23, 2008 4:09 AM
  • User-833084849 posted

    Session not start in browser because session only managed by IIS so browser is a gateway. So through gateway you can start session and you can also end session but auto end facility is not with browser. if you want to embed it you should create your own web browser.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2008 5:33 AM
  • User-1773948845 posted

    I dont know how Session.Abadon works. If it is working in IIS or in aspnet_wp.exe then there could be possible of closing the browser when the Session.Abandon is called.It is my suggestion for future browsers.

     

    Tuesday, June 24, 2008 7:12 AM
  • User1174340047 posted

    hi, Ganesh@Nilgris.

    i think your confuse derives from your misunderstanding of how HTTP works. A broswer and a web server communicate with each other throught HTTP, the broswer can send http request to the web server whenever it wishes to, but the web server can send http response to the broswer only when it receives a http request from the broswer, otherwise the web server has no way to send http response because the web server just has no idea which broswer to send the response. That's to say, the broswer and web server have a active-passive relationship.

    If the browser can "think" that it has to fire the "Session_start" event at the time of browser starting the page

    whether to fire the session_start event is not determined by the broswer, it is determined by the web server (actuallythe asp.net runtime). The Asp.net runtime checks whether the request contains the "ASP.NET_SessionId" cookie. if it doesn't contain, asp.net start a new session for the request.

    the browser should be able to "think" that it has to fire the "Session_end" event at the time of closing the browser

    The same logic as session_start event. According to the timeout property of the session, asp.net determines when to remove a session, all this is finished without the participancy of the broswer. Additionally, the web server has no way to notify this "session time out" to the broswer.

     I think this should be helpful to you. Let me know if you still are confused.Thank you.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 26, 2008 11:24 AM
  • User1174340047 posted

    why the browser is not intelligent enough to call a "session_end" event when the browser closes?

    base on my previous post, this question should be "why the browser is not intelligent enough to do a postback or callback to tell the web server to execute Session.Abandon() when the broswer is closed?"

    I think this is because the HTTP doesn't include such a requirement. i think it makes sense to do so:

    1.it is necessary to tell the web server only when session is enabled, but the broswer has no way determine whether session is enabled in the web server.

    2. even the broswer has a way to determine whether session is enabled in the web server, there is overhead to send another http request to the web server just to tell it to abandon the session.

    Thursday, June 26, 2008 11:38 AM