forcing new session id without closing browser

A

Andy G

Is it possible to force a new session id without the client closing the
browser? I'm using session id in my database and I need a new session id
when a client clicks a certain link. I know I could use my own id in the
database but I was wondering if the the above is possible.

I tried using Session.Abort() and Session.Clear() and used both of them
together and the session id still persists.

Thanks.
 
P

Patrice

Try Session.Abandon.

Don't know for Abort but Clear just clears the session variable...
 
D

Dave Johnson

SURE session.Abandon will work just fine as its the best way to do it,
but you may also want to check somthing like this
Session.Timeout(0.0000000001) will make the user starts a new session
when he makes any interaction with the target page if you ever find it
helpful in your scenario !

session.LCID gets or sets locale identifer for the session, u may want
to check it out too

Sharing makes All the Difference
 
A

Andy G

Sorry I meant to say Abondon in my previous message.

Abondon will not force ASP.NET to create a new session ID. Abondon calls
the Session_End and then the Session_Start, so really it doesn't do much
different than Clear.

I'm going to try using the session.timeout(0.00000001), whatever Dave
suggested below.
 
A

Andy G

Well I've found some weird stuff and I hope someone can shed some light on
this.

Using the below on the page load will force ASP.NET to get a new Session
variable. I tried to put this same code on a button click event and it
didn't work. I tried it checking the post back and then leaving it out,
didn't make a difference. So the question is, what can Page_Load do/have
access to that a button click event doesn't?

FORCE ASP.NET TO GET A NEW SESSION VARIABLE
If Not IsPostBack Then

Request.Cookies("ASP.NET_SessionId").Expires = Now

End If



Hope some of this helps you guys. Thanks for the help too.

-Andy
 

rlo

Joined
May 21, 2009
Messages
1
Reaction score
0
How and why session IDs are reused in ASP.NET and how to not reuse the same SessionID

I had the similar problem before. I found this article at Microsoft website with article# 899918. It explains how the session state works and why the system reuse the same SessionID, and also how to not reuse the same SessionID.

To cancel the current sessions state and regenerate the SessionID, use the following commands:

Session.Abandon();
Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top