Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ok, I found this on the web: Que

Status
Not open for further replies.

gagz

Programmer
Nov 21, 2002
333
US
Ok, I found this on the web:

Question:
I call Session.Abandon after a person completes an order. The users session is expired and they have to relogin. Great! The issue is that the sessionID stays the same. From what I understand, this is suppose to change every time a new session is created. Is this true?

Answer:
Session.Abandon only releases the memory used by session variables and frees the server resources used by that session. Session ID is stored on the client side (as a cookie) and is unaffected by the Abandon method. As such, the session effectively restarts, but retains the session ID.

Sounds nice, but I need to know how to find out that the session has been abandoned in code. Ie, I have pages that look to see if there is a session active, if there is not, redirect to the login page. So i was hoping I could use:
Code:
If (Session.SessionID = "") Then

but that doesn't work.

In my logout page i'm doing:
Code:
'delete cookies       
Response.Cookies("MyCookie").Value = ""
            
'end session
Session.Abandon

and was hoping that would be enough...

Can someone shed some light? I need to know how to tell if there session has ended.

Thanks.
 
Hi
You could try
If session.isnewsession - this will tell you if the session was created with the current request, and seems to be true following a session.abandon

Otherwise, you could put a custom flag in the session_onstart event in global.asax

session("Flag") = "OK"

and then test for this. If you do it this way, you may need a session.clear as well as the session.abandon

Hope this helps


Mark [openup]
 
Mark-

Thanks, thats basically what I ended up doing... I just checked for the existance of a session variable, not ID, and it seems to be working... So the variable thats already there became my 'flag' so to speak.

thanks,
Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top