-
Session object
I'm having this problem of passing session object. When i move from one hyperlink to another, my session object becomes empty.
say:
in page1.aspx
Session("isValid") = True
and when i clicked on the hyperlink
<a href=page2.aspx></a>
it still goes to page2 but I can't get the value of Session("isValid"), when i try to trace it, it is empty.
I've tried using response.redirect, but still the same prob.
so, how can i pass session around the pages?
:confused:
-
In your web.config file, there should be a tag with an attribute that lets you turn on/off session state management. Make sure this switch isn't set to false.
-
I've check, It is on....
I'm totally confused....
-
post your code if you don't mind...i too have been working with session objects recently and have had good luck passing and retaining values...
Ooogs
-
Try to use relative path e.g. ./ and ../
-
I started with the login page where user enter password and id, this is how i set the session object if the user exist.
Dim objComm As New SqlCommand(strSQL, objConn) ' Reserve space in memory 'for the SqlCommand object
Dim objReader As SqlDataReader
Try
objConn.Open()
objReader = objComm.ExecuteReader()
If objReader.Read() = False Then
Session("Invalid") = "True"
Return False
Else
Session("Invalid") = ""
Session("LoggedIn") = "True"
Session("UserID") = objReader.Item("UserID").ToString
Session("Category") = objReader.Item("Mem_Category").ToString
Return True
End If
Finally
End Try
objReader.Close()
objConn.Close()
Then, i transfer the user to different page according to their member category by using server.transfer.
server.transfer("Member.aspx")
in Member.aspx page, I still manage to retrieve all info in the Session object, including session("userID").
but when i clicked on a hyperlink that link to another page, it show error that object reference not set to an instance of object in this line of code
" dim str
str= session("UserID")"
btw, the hyperlink is inside a user control, does it matter?