Hi all, in my app a user places an order and should be assigned a new session id.

Then they should be able to place a new order using this session id so as not to ovewrite their previous orders data. Unfortunately the only way I can get a new session id is by calling

HttpContext.Current.Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));

which then logs the user out.

If I call

System.Web.Security.FormsAuthentication.SetAuthCookie(username, true);

to log the user back in HttpContext.Current.User.Identity.IsAuthenticated == false and so they still have to log in.

Is there a way that I can create a new session and keep the user logged in, or create a new session and then log the user in programmatically without them being redirected?

Recommended Answers

All 2 Replies

You can generate a new session id by remove value of cookie.

Response.Cookies["ASP.NET_SessionId"].Value = "";

See - http://support.microsoft.com/kb/899918

Thanks adatapost, but I found my issue wasn't that IsAuthenticated was false after all.

I just needed to redirect the page back to itself for the new session to take, and then set all the session variables I had by previously storing them and then retrieving them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.