views:

13

answers:

1

I have a website which is behaving oddly in terms of creating new sessions. When I fire up the website, the Session_Start event fires as you would expect and the page loads fine. No error is encountered and everything runs fine. The next time you click a link to cause a new page to load, Session_Start fires again and a new session is initialised, losing the data from the previous page impression. Thereafter, you can navigate around the site as much as you want and the session remains consistent, never firing Session_Start again until you would expect (new browser window etc.). and visiting the same page as the site started with without this happening again.

I can’t see anything obvious as to why it would do this, but I need to resolve it as it is making session tracking inaccurate, and its driving me nuts as I can’t explain why. Has anyone seen this or is anyone able to offer a theory as to why?

Thanks

A: 

Asp.net sessions are handled using cookies, a cookie (typically) named *ASP.NET_SessionId*. If the second request its issued before the cookie is set the first time, you'll get a new session. If this is not the case, follow/inspect the value of the asp.net session cookie using a browser tool like Firebug.

jorgebg
Ah, found the problem. When the website was being fired up, the ASP.NET_SessionId cookie was being set with a domain ‘localhost’ as you would expect. Then, subsequent page requests were being made to http://<MACHINE NAME>/another/page.aspx due to a debug entry put in the web.config used to track issues in IE6!Looking at the cookie with FireCookie helped diagnose this – thanks as I doubt i’d ever have worked that out otherwise and found a great little tool in the process! :)
LDJ