Thursday, March 22, 2012

Session Variables

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!!!!!!!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"
/
>--Original Message--
>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!!!!!!!
>.
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.

>--Original Message--
>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!!!!!!!
>.
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.

"Jim Heavey" <JimHeavey@.nospam.com> wrote in message
news:Xns94396D1DDA62FJimHeaveyhotmailcom@.207.46.24 8.16...
> 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!!!!!!!
Oops.

That For loop should have been

For i=0 To Session.Count - 1

but I'm sure you spotted that.

"Marc" <nomail@.nospam.com> wrote in message
news:%23AixLtEsDHA.2408@.tk2msftngp13.phx.gbl...
> 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.
> "Jim Heavey" <JimHeavey@.nospam.com> wrote in message
> news:Xns94396D1DDA62FJimHeaveyhotmailcom@.207.46.24 8.16...
> > 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!!!!!!!
Thanks!!!!

0 comments:

Post a Comment