I've got a website which uses Session variables to keep track of the currently logged in userid. When a user logs in we set a session variable:
Session("ActiveCustomerID"
) = rs(0)
Once logged in, getting the user account works fine... ActiveCustomerID= Session("ActiveCustomerID"
)
however we have a case where we need to set Other Sessions, we do this on one page. Session("ActiveCustomer") = "56"
This value, is not recognized on any other page, the same page would recognize the value from our normal login procedure. For testing/example purposes I've also create a Username and Age session variable and assigned some values.
Code Snippits:
--------------------------
-
Page one:
<%
Session("username")="Donal
d Duck"
Session("age")=50
Session("ActiveCustomerID"
)="37"
%>
<!-- #include File="loginPage.asp" -->
<%
Username=Session("username
")
age=Session("age")
%>
<div class="channel-text"> 
;Active username is: <%=Username %> and age is <%=age %></div>
<a href="testSession.asp">Tes
t Session Page</a>
---------- both username and age can be displayed normally on this page, however they are missing on the TestSession.asp page -----------------
Page2: LoginPage.asp
Set RS = Conn.Execute(SQL)
If NOT RS.eof and not rs.bof then
Session("ActiveCustomerId"
) = rs(0)
[other unrelated stuff here]
Response.Redirect "UserHome.asp"
--------------------------
-this page works OK and sets ActiveCustomerID ---------------------
Page3: UserHome.asp
<a href="testSession.asp">Tes
t Session Page</a>
Page4: TestSession.asp
<html xmlns="
http://www.w3.org/1999/xhtml"
>
<head>
<title>Test of session passing</title>
</head>
<body>
<%
Username = Session("username")
age = Session("age")
ActiveCustomerID = Session("ActiveCustomerId"
)
%>
<span>
Username: <%=Username %> <br />
age: <%=age %> <br />
ActiveCustomerID: <%=ActiveCustomerID %> <br />
</span>
</body>
</html>
Here username and age are missing but active customer ID is there (if you have logged in). Basically setting username and age do not work but setting activeCustomer ID does.
Any ideas would be greatly appreciated?
Start Free Trial