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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session variable stays after session.abandon

Status
Not open for further replies.

youngun

Programmer
Apr 27, 2001
61
US
When a person login into my website (default.asp), I check the userid and password and then assign a session variable session("loginSuccess) = "Y" or "N" for yes or no.

In my logout.asp, I have
session.abandon
which calls the Session_OnEnd function in global.asa.

In global.asa, I have
Sub Session_OnEnd
session("loginSuccess") = ""
end sub

and when I manually type in " it somehow still allows me to go into that page.

In menu.asp, I have
if session("loginSuccess") = "Y" then
...
end if


Can somebody help me debug this annoying code?

Thank you.
 
Hello,
See what MSDN says:
========================================================
Abandon
The Abandon method destroys all the objects stored in a Session object and releases their resources. If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.

Syntax
Session.Abandon

Remarks
When the Abandon method is called, the current Session object is queued for deletion, but is not actually deleted until all of the script commands on the current page have been processed. This means that you can access variables stored in the Session object on the same page as the call to Abandon, but not in any subsequent Web pages.

For example, in the following script, the third line prints the value Mary. This is because the Session object is not destroyed until the server has finished processing the script.

<%
Session.Abandon
Session(&quot;MyName&quot;) = &quot;Mary&quot;
Reponse.Write(Session(&quot;MyName&quot;))
%>

If you access the variable MyName on a subsequent Web page, it is empty. This is because MyName was destroyed with previous Session object when the page containing the above example finished processing.

The server creates a new Session object when you open a subsequent Web page after abandoning a session. You can store variables and objects in this new Session object.

Example
The following example causes the session state to be released when the server finishes processing the current page.

<% Session.Abandon %>

=======================================================
In your case I would suggest to empty the cache.
See thread333-78530 for vey useful tips.
Hope this helps.
D.
 
hi
how can i use session in script
i have a page with login and after a user get his session i want to prevent a case the user need to login again
thanks shon
 
hi
how can i use session in script
i have a page with login and after a user get his session i want to prevent a case the user need to login again
thanks shon
 
you read in user's login like this:

session(&quot;username&quot;) = request.form(&quot;login_id&quot;)

then from now on, you can use session(&quot;username&quot;) in any page.

For example, in another page you can write code:

if session(&quot;username&quot;) = &quot;Shon&quot; then
......
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top