How to rewrite SessionID?

by dee 17. January 2008 01:03

The only possibility to make that trick it is to change "ASP.NET_SessionId" cookie before ASP.NET has loaded session state. It can be achieved by handling PostMapRequestHandler application event. For example:

 

void Application_PostMapRequestHandler(object sender, EventArgs e)
{
    string aspNetSessionName = "ASP.NET_SessionId";
    if (Request.Cookies[aspNetSessionName] != null)
    {
        Request.Cookies[aspNetSessionName].Value = "new session ID";
    }
    else
    {
        HttpCookie sessionIDCookie = new HttpCookie(aspNetSessionName, "new session ID");
        Request.Cookies.Add(sessionIDCookie);
    }
}

Powered by BlogEngine.NET 1.4.0.0
Theme by Mads Kristensen