tags:

views:

53

answers:

1

The default cookie name for the Session Id in ASP.NET is ASP.NET_SessionId. It's also possible to change this name to something else like <sessionState cookieName="FooBar" />.

Is there a member to easily access this name like with FormsAuthentication.FormsCookieName?

+3  A: 

Taking into account that you say that you set an different name for the cookie on the web.config then I'd say you could read the cookie name from there

SessionStateSection sessionStateSection =
  (System.Web.Configuration.SessionStateSection)
  ConfigurationManager.GetSection("system.web/sessionState");

string cookieName =  sessionStateSection.CookieName;
Claudio Redi
Ok but what about the case where it *doesn't* get changed? Will this return the default value of `ASP.NET_SessionId` as well?
TheCloudlessSky
Yes, when you didn't change it you get "ASP.NET_SessionId"
Claudio Redi
Awesome thanks!
TheCloudlessSky