I was having the same problem! Here is what I've found after long search: (found here (
http://www.avdf.com/oct97/art_id002.html)
"Help, my Session variables disappeared!" Actually, that's probably what they were "supposed" to do (ahem!). If you change virtual directory or server, ASP allocates a new Session ID. Which sort of makes sense… and sort of doesn't. The net effect is that, for session variables to be maintained, you must stay within a directory (and its subdirectories).
Your redirect is probably changing directories too. I'm going to move my pages to the root and see if that helps. Good Luck! Gerard
If
Quote:
Originally posted by hktang
Hi people,
I have a problem with session variables lost while redirecting to other pages.
What the codes does is to ask the user to sign in. If success authenticate the user, member ID will be assign to the session. And the next page will do a check on member ID in session.
Sign-in page :
- The usual form asking for password and email
Login page :
<%
If Success Login Then
Session("memberID") = Member ID
Response.Redirect "Page 1"
Else
Response.Redirect "login.asp?mode=2"
End If
%>
Page 1 :
<%
If Session("memberID") = 0 Then
Response.Redirect "login.asp?mode=1"
End If
%>
So, page 1 simply enforce user to login before viewing its content. The problem here is, in login page, the member ID does exists in session. But while redirecting over to Page 1, the member ID is lost !
I have got a few facts over the web, which does not apply in my case.
1. There are no Session.abandon been called in anywhere. No way the session data can be cleared away.
2. My server is on a workgroup and has no invalid characters ( refer http://support.microsoft.com/default...b;EN-US;316112 for one of the possible caused of session not persist)
3. The value does exists and stay in session while I am in login.asp... it just never stay alive till the next page.
4. I have testing on a few different PC and the same problem occurs
5. I use no frame for the webpages ( refer http://support.microsoft.com/default...;en-us;q178037 - this is applicable to IE 4,5 only)
6. Yes, the browser is cookies enabled
7. The pages are tested locally, never go through any firewall (I have read somewhere that ASP session might lost while travelling through firewall)
8. Standard session timeout : 20 minutes
All the server I have tested is running Win2k Server, IIS5, IE6.
Any idea what went wrong? Please advise.
Thanks in advance.
|