End a Session

Results 1 to 3 of 3

Thread: End a Session

  1. #1
    Join Date
    Dec 1969

    Default End a Session

    Ok, I found this on the web:<BR><BR>Question:<BR>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? <BR><BR>Answer: <BR>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.<BR><BR>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:<BR><BR>If (Session.SessionID = "") Then<BR><BR><BR>but that doesn&#039;t work. <BR><BR>In my logout page i&#039;m doing:<BR><BR>&#039;delete cookies <BR>Response.Cookies("MyCookie").Value = ""<BR> <BR>&#039;end session<BR>Session.Abandon<BR><BR><BR>and was hoping that would be enough... <BR><BR>Can someone shed some light? I need to know how to tell if there session has ended.<BR><BR>Thanks.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: End a Session

    When the user makes the first request to an ASP page on your web server, they get assigned a session ID. Therefore, when your page starts to execute, they have a session ID. By the time your page executes, they NEVER have a blank session ID.<BR><BR>The way to do it is to populate a session variable when they log in, and check to see if that exists. If it doesn&#039;t exist (is blank), then redirect them to the login page...<BR><BR>Craig.

  3. #3
    Join Date
    Dec 1969

    Default This article will enlighted you


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts