Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6227713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:16:09+00:00 2026-05-24T09:16:09+00:00

The system I am working on does not use standard ASP.NET Auth/ Membership facilities

  • 0

The system I am working on does not use standard ASP.NET Auth/ Membership facilities for logging users in/ out. Therefore after logging the user in I want to issue a new Session ID to the user in order to prevent Session trapping/ Hijacking. The problem i have is that although I have been able to successfully create a new session with a new ID and copy the various components to the newly created session eg. session[“value”]. By the end of the code excerpt below the newly created session is the current HTTPContext’s session, and has the session values that were copied accross. However after performing a Response.Redirect the new session is in action, but none of the session[“values”] have persisted across the two requests. As you can see from the code below i’ve tried adding the values to a number of collections to avail.

Any help would be amazing!! Thanks in advance

    bool IsAdded = false;
    bool IsRedirect = false;

    HttpSessionState state = HttpContext.Current.Session;        
    SessionIDManager manager = new SessionIDManager();
    HttpStaticObjectsCollection staticObjects = SessionStateUtility.GetSessionStaticObjects(HttpContext.Current);
    SessionStateItemCollection items = new SessionStateItemCollection();

    foreach (string item in HttpContext.Current.Session.Contents)
    {
        var a = HttpContext.Current.Session.Contents[item];
        items[item] = a;
    }  

    HttpSessionStateContainer newSession = new HttpSessionStateContainer(
                                                    manager.CreateSessionID(HttpContext.Current),
                                                    items,
                                                    staticObjects,
                                                    state.Timeout,
                                                    true,
                                                    state.CookieMode,
                                                    state.Mode,
                                                    state.IsReadOnly);

    foreach (string item in HttpContext.Current.Session.Contents)
    {
        var a = HttpContext.Current.Session.Contents[item];
        newSession.Add(item,a);
    }



    SessionStateUtility.RemoveHttpSessionStateFromContext(HttpContext.Current);

    SessionStateUtility.AddHttpSessionStateToContext(HttpContext.Current, newSession);

    manager.RemoveSessionID(HttpContext.Current);
    manager.SaveSessionID(HttpContext.Current, newSession.SessionID, out IsRedirect, out IsAdded);

    return newSession.SessionID;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:16:10+00:00Added an answer on May 24, 2026 at 9:16 am

    Basically it appears it’s not possible since you can only add session variables once there has been one round trip to the client to create the corresponding session cookie. Therefore I had to create the new new session (with new ID) so that by the time I came to adding session variables, the client cookie had the appropriate session id: annoying since this in reality is issuing the new session ID before the user is authenticated.

    Interestingly, it seems a little strange that issuing a new Session ID is exactly what the standard asp.net authentication/ membership functionality does but is able to maintain session variables, and yet doing it manually it doesn’t….are there some methods for this that are not being exposed to us mere developers maybe….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have various interrelated projects in my Eclipse Helios workspace. Some projects use the
BACKGROUND I have been working on a tool that is supposed to work in
I've set up a simple gallery system in PHP that is built to display
A website I'm working on is using a third-party assembly, let's say A.dll. This
I'm trying to write a console application that will run and remove/add items to
PEP 8 says that Python package and module names should be short, since some
I have built a website which uses ajax for most of the sites functions
I'm currently using two images for a menu that I've built. I was using
In a recent post ( My program never releases the memory back. Why? )
I'm trying to generate two random numbers, one for a row and one for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.