Session Variables

J

Jim Heavey

How would I iterate over the session varriables listing all the names of
the session variables which currently exist?

Why would it be that if I set a session variable and then immediately
redirect to another page, why would the session varriable not be in
existence?

Thanks in advance for your assistance!!!!!!!
 
A

Adrijan Josic

Session variables are stored immediately I believe so you
must be losing your session from page to page. Check if
you have declared enableSessionState=true in the
<@Page ...> directive on all pages that use the session.
You can also paste something like this into your
web.config to enable session for all pages:
<pages
enableSessionState="true"
/>
 
M

Marcelo

Jim, session time-outs will cause session object to loose
their values. Here is a very simple example of creating a
session object, redirecting to another page and then
reading the session object value:

Page 1
======

Page.Session("NewAccount") = "True"
Page.Response.Redirect("summaryPage.aspx", True)

Page 2
======

If (Page.Session("NewAccount") = "True") Then

End If

I hope this helps.
 
M

Marc

Hi,

For your first questio, to list your session variables, the following
should work

Dim i As Integer

For i=1 To Session.Count
Response.Write(Session.Keys(i) & " = " & Session.Item(i) & "<br>")
Next

For your second question, session variables not being retained from
one page to the next.

Do you use ZoneAlarm Pro? If so, you need to enable third party
cookies for your local site. IIS uses a cookie to propogate the
SessionID from page to page, and it may be that ZoneAlarm is dropping
this cookie, so when IIS gets to the next page it thinks it's a new
session. (I had this problem myself, which took about a week before I
found the answer (on this newsgroup, I think)).

Marc.
 
M

Marc

Oops.

That For loop should have been

For i=0 To Session.Count - 1

but I'm sure you spotted that.
 

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

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top