How to Generate a new Session ID
You can do this using the SessionIdManager class:
SessionIDManager manager = new SessionIDManager();string newID = manager.CreateSessionID(Context);bool redirected = false;bool isAdded = false;manager.SaveSessionID(Context, newID, out redirected, out isAdded);
[Code sample is from Anas Ghanem's article]
you can use
SessionIDManager.CreateSessionID Method :
returns a unique session identifier that is a randomly generated number encoded into a 24-character string.
Code
SessionIDManager Manager = new SessionIDManager(); string NewID = Manager.CreateSessionID(Context); string OldID = Context.Session.SessionID;bool redirected = false;bool IsAdded = false;Manager.SaveSessionID(Context, NewID,out redirected, out IsAdded);
Here you can find full detail about hsi : Changing the session ID programmatically.
yes it is possible to generate new ID for the session.below is one example
SessionState.SessionIDManager Manager = new SessionState.SessionIDManager(); string NewID = Manager.CreateSessionID(Context); string OldID = Context.Session.SessionID; bool IsAdded = false; Manager.SaveSessionID(Context, NewID, false, IsAdded); Response.Write("Old SessionId Is : " + OldID); if (IsAdded) { Response.Write("<br/> New Session ID Is : " + NewID); } else { Response.Write("<br/> Session Id did not saved : "); }