Click to See Complete Forum and Search --> : session.abandon
esthera
12-08-2004, 05:23 AM
Is there anything wrong with doing this:
Session.abandon
session("name")="name"
I want to abandon all sessions and then set a new session.
The above code didn't seem to set the new session.
scragar
12-08-2004, 07:50 AM
when using session.abandon you'r unable to asign any new session variables for the duration of the page, you might want to try seting the timeout to -1
Session.Timeout=-1
esthera
12-08-2004, 01:03 PM
SessionID error 'ASP 0164 : 80004005'
Invalid TimeOut Value
/sc/checkout.asp, line 42
An invalid TimeOut value was specified.
scragar
12-09-2004, 04:12 AM
Doh, I forgot ASP wes so annoying...
esthera
12-09-2004, 04:44 AM
is there any other solution that will work?
scragar
12-09-2004, 05:09 AM
I quick fix would be to have a binary value, if it's true then ignore session information, and treat it although the session variables are blank, otherwise read from them normaly.
at the end of the page if it's false than run session.abandon
esthera
12-09-2004, 05:13 AM
no because what I really need to do is destroy the session (so session.id changes) but I want to save one field from the session called session("name") so I have the name.
russell
12-09-2004, 12:51 PM
put it in a cookie
esthera
12-09-2004, 01:05 PM
but don't a lot of machines disable cookies?
Is there any other way. Anyway to set the timeout?
russell
12-09-2004, 01:11 PM
you can set the session timeout to any value > 0 that you want. but that should be done in the global.asa and affects all sessions. Thsi si used to automatically expire a session after a fixed perod of inactivity.
When you use session.abandon, you should also explicitly set all session variables to empty string, then do a response.redirect to some landing page.
Sessions are maintained by a cookie. If the user doesn't have cookies enabled, ya got no session anyway.
Go to any asp page and in the location bar of your browser, type: javascript:alert(document.cookie);
You'll see the AspSessionId cookie right there...
esthera
12-09-2004, 01:48 PM
I actually have never used cookies -- so I could set the cookie and then do session.abandon and in the next page reset the session?
russell
12-09-2004, 01:54 PM
after the response.redirect, a new session should automatically be created. set cookies like this
Response.Cookies("CookieName") = someValue