Labels

Wednesday, August 6, 2008

Gotcha - Session Start & Sesssion_End Event

Hi,

Below covers the gotcha with SessionStart and SessionEnd.

Session Start & Sesssion_End Event

Ø Start event fires only for the one time when the very first page is requested in the browser. i.e it does not fire for the any number of next or same page request.

Ø Session End event fires when Session is timeouted out or LogOut fired using below code.

Ø Once End fires, Start event refires when again a very first page is requested in the browser.

System.Web.Security.FormsAuthentication.SignOut();

Session.Abandon();

Gotcha –

Ø Once the Start event is fired on the very first page request, if there is some link in that page, which opens another page in a new browser window, then it does not lead to fire Session Start.

Ø Now on this new page which is a new window - If you fire logout, then the Session End fires. This end event ends the session for the parent window (which opened the seperate window) as well.

Ø Once the Start event is fired on the very first page request. Now if you copy the url and paste in another browser window – This leads to to fire another Session Start.

Ø Now on this new page which is a new window - If you fire logout, then the Session End fires. But this end event ends the session of only the new window and not of the parent window (which opened the seperate window) as well.

In an all the Session State would be same for two separate Browser widnows, provided the new window has been opened from the parent widnow code. This is the Gotcha

But Session State would be different for two separate Browser widnows, provided the new window is opened by opening a new browser instance. This is the Gotcha

Thanks & Regards,

Arun Manglick || Senior Tech Lead


No comments:

Post a Comment