Sharing session variables between pages

J

John Devlon

Hi,

I've created 2 pages. On the first page i've created 2 session variables.
Going to the second page using the redirect function, the session variables
can't be located. Do i have to enable the session features in de web config
file or is there something else that went wrong?
Does anyone have an idea?

Page 1
Session("Login") = "John"
Session("Password") = "admin"
response.redirect("nextpage.aspx"")

Page 2
Dim strLogin as string = Session("Login")

Session("Login") is emty ....

Does anyone have an idea?

Thanx
john
 
N

Norm

Dim strLogin As String = Session("Login").ToString()

Mark's solution should work, but I would like to add something:

Dim strLogin as string = Session("Login")
The above code depends on an implicit conversion from object to
string. The session object is a collection of objects, not strings.
This means that you are not using Option Strict. I would highly
recommend you do so. It is a simple way to prevent bugs at compile
time instead of finding them at runtime.

- Norm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top