By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

Session variables

P: n/a
Hi all,

Is there any limit to the number of session variables a site can have? And
is that affected by global.asa at all?

The reason why i ask is that i have a relatively simple site that relies on
about 40 sesion variables and a mixture of vbs and js files. One of the
session variables is an id number that gets incremented to point to the next
piece of data to be displayed. This variable is initialised on the first
page of the site and then incremented. However, if you quit the site, and
then access the site again, this variable is not reset to its initial value.

Any ideas?

Martin
Jun 1 '06 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Martin Walke wrote:
Hi all,

Is there any limit to the number of session variables a site can
have? And is that affected by global.asa at all?

The reason why i ask is that i have a relatively simple site that
relies on about 40 sesion variables and a mixture of vbs and js
files. One of the session variables is an id number that gets
incremented to point to the next piece of data to be displayed. This
variable is initialised on the first page of the site and then
incremented. However, if you quit the site, and then access the site
again, this variable is not reset to its initial value.

Unless you close all browser windows that were open when the session was
begun, you will not get a new session.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 1 '06 #2

P: n/a
> Unless you close all browser windows that were open when the session was
begun, you will not get a new session.
Thanks Bob but yep - knew that. But in this case, I'm setting the variable
to its initial value but that doesn't seem to be happening. So i'm just
wondering what would stop a session variable from being updated to a new
value.

Martin

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:uP**************@TK2MSFTNGP02.phx.gbl... Martin Walke wrote:
Hi all,

Is there any limit to the number of session variables a site can
have? And is that affected by global.asa at all?

The reason why i ask is that i have a relatively simple site that
relies on about 40 sesion variables and a mixture of vbs and js
files. One of the session variables is an id number that gets
incremented to point to the next piece of data to be displayed. This
variable is initialised on the first page of the site and then
incremented. However, if you quit the site, and then access the site
again, this variable is not reset to its initial value.

Unless you close all browser windows that were open when the session was
begun, you will not get a new session.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jun 1 '06 #3

P: n/a
Martin Walke wrote:
Unless you close all browser windows that were open when the session
was begun, you will not get a new session.
Thanks Bob but yep - knew that. But in this case, I'm setting the
variable to its initial value but that doesn't seem to be happening.


When/where are you doing that?
So i'm just wondering what would stop a session variable from being
updated to a new value.

Nothing that I know of.
Could you explain the process in a little more detail?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 1 '06 #4

P: n/a
Martin Walke wrote:
Unless you close all browser windows that were open when the session
was begun, you will not get a new session.


Thanks Bob but yep - knew that. But in this case, I'm setting the
variable to its initial value but that doesn't seem to be happening.
So i'm just wondering what would stop a session variable from being
updated to a new value.

I suspect that what is happening is that you are not getting a new
session when you expect to be getting one. The best way to confirm this
is to display the session id, which should change when a new session is
started.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 1 '06 #5

P: n/a
Bob Barrows [MVP] wrote:
Unless you close all browser windows that were open when
the session was begun, you will not get a new session.


Well, that's not entirely true. You ought to get a new one after
Session.Abandon().

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Jun 1 '06 #6

P: n/a
Thanks for the responses guys.

OK.. maybe I'm confused about session variables. My site opens in a new
window from a link. I have a line

<%
....
session("qid") = 0
....
%>
that is on the first page of my site. This session variable is used to
determine what information is to be shown on the next page. The next page
increments this session variable and after user interaction, the page is
shown again (but with different info) based on the value of 'qid'.

<%
....
session("qid") = session("qid") + 1
....
%>

If the user then quits this site (but doesn't close all browser windows) and
then returns to the site, the session variable is not reset to 0 on the
first page.

The real rub here is that it works on 3 other servers, plus PWS, but not on
the client's live server. What gives?

Martin

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:u9**************@TK2MSFTNGP03.phx.gbl...
Bob Barrows [MVP] wrote:
Unless you close all browser windows that were open when
the session was begun, you will not get a new session.


Well, that's not entirely true. You ought to get a new one after
Session.Abandon().

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.
Use of this email address implies consent to these terms.

Jun 2 '06 #7

P: n/a
Martin Walke wrote on 02 jun 2006 in
microsoft.public.inetserver.asp.general:
OK.. maybe I'm confused about session variables. My site opens in a
new window from a link. I have a line

<%
...
session("qid") = 0
...
%>
that is on the first page of my site. This session variable is used to
determine what information is to be shown on the next page. The next
page increments this session variable and after user interaction, the
page is shown again (but with different info) based on the value of
'qid'.

<%
...
session("qid") = session("qid") + 1
...
%>

If the user then quits this site (but doesn't close all browser
windows) and then returns to the site, the session variable is not
reset to 0 on the first page.

The real rub here is that it works on 3 other servers, plus PWS, but
not on the client's live server. What gives?


It should "work". Try making a minimalistic test set of files and try it
again. Also try it with other browsers and from othe url's.

==========================

Why not use a "work-around" and do the initializing on the counting page?
This is a must anyway if that page is accessable after timeout or from an
external link or bookmark anyway:

<%
....
if session("qid") = "" then session("qid") = 0
session("qid") = session("qid") + 1
....
%>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 2 '06 #8

P: n/a
Ermmmm.... this might be a silly question, but have you checked to see
if Enable Session State has been checked in the Application
configuration on your client's server?

--
Mike Brind

Martin Walke wrote:
Thanks for the responses guys.

OK.. maybe I'm confused about session variables. My site opens in a new
window from a link. I have a line

<%
...
session("qid") = 0
...
%>
that is on the first page of my site. This session variable is used to
determine what information is to be shown on the next page. The next page
increments this session variable and after user interaction, the page is
shown again (but with different info) based on the value of 'qid'.

<%
...
session("qid") = session("qid") + 1
...
%>

If the user then quits this site (but doesn't close all browser windows) and
then returns to the site, the session variable is not reset to 0 on the
first page.

The real rub here is that it works on 3 other servers, plus PWS, but not on
the client's live server. What gives?

Martin

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:u9**************@TK2MSFTNGP03.phx.gbl...
Bob Barrows [MVP] wrote:
Unless you close all browser windows that were open when
the session was begun, you will not get a new session.


Well, that's not entirely true. You ought to get a new one after
Session.Abandon().

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.
Use of this email address implies consent to these terms.


Jun 2 '06 #9

P: n/a
Thanks Mike. No I haven't but only as they use Session variables for various
security checks etc and have therefore assumed (cough) that that side would
be OK. I'll double check though.

It may be that this is not really an ASP problem but an IIS problem and is
being visualised as a session variable issue.

Martin
"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11*********************@h76g2000cwa.googlegro ups.com...
Ermmmm.... this might be a silly question, but have you checked to see
if Enable Session State has been checked in the Application
configuration on your client's server?

--
Mike Brind

Martin Walke wrote:
Thanks for the responses guys.

OK.. maybe I'm confused about session variables. My site opens in a new
window from a link. I have a line

<%
...
session("qid") = 0
...
%>
that is on the first page of my site. This session variable is used to
determine what information is to be shown on the next page. The next page
increments this session variable and after user interaction, the page is
shown again (but with different info) based on the value of 'qid'.

<%
...
session("qid") = session("qid") + 1
...
%>

If the user then quits this site (but doesn't close all browser windows)
and
then returns to the site, the session variable is not reset to 0 on the
first page.

The real rub here is that it works on 3 other servers, plus PWS, but not
on
the client's live server. What gives?

Martin

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:u9**************@TK2MSFTNGP03.phx.gbl...
> Bob Barrows [MVP] wrote:
>> Unless you close all browser windows that were open when
>> the session was begun, you will not get a new session.
>
> Well, that's not entirely true. You ought to get a new one after
> Session.Abandon().
>
>
>
> --
> Dave Anderson
>
> Unsolicited commercial email will be read at a cost of $500 per
> message.
> Use of this email address implies consent to these terms.
>

Jun 2 '06 #10

P: n/a
> Why not use a "work-around" and do the initializing on the counting page?
This is a must anyway if that page is accessable after timeout or from an
external link or bookmark anyway:
Thanks Evertjan. That's certainly something I can do anyway but perhaps the
symtoms are pointing to something else being wrong and it's just manifesting
itself as the inability to set session variables.

Martin
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.242... Martin Walke wrote on 02 jun 2006 in
microsoft.public.inetserver.asp.general:
OK.. maybe I'm confused about session variables. My site opens in a
new window from a link. I have a line

<%
...
session("qid") = 0
...
%>
that is on the first page of my site. This session variable is used to
determine what information is to be shown on the next page. The next
page increments this session variable and after user interaction, the
page is shown again (but with different info) based on the value of
'qid'.

<%
...
session("qid") = session("qid") + 1
...
%>

If the user then quits this site (but doesn't close all browser
windows) and then returns to the site, the session variable is not
reset to 0 on the first page.

The real rub here is that it works on 3 other servers, plus PWS, but
not on the client's live server. What gives?


It should "work". Try making a minimalistic test set of files and try it
again. Also try it with other browsers and from othe url's.

==========================

Why not use a "work-around" and do the initializing on the counting page?
This is a must anyway if that page is accessable after timeout or from an
external link or bookmark anyway:

<%
...
if session("qid") = "" then session("qid") = 0
session("qid") = session("qid") + 1
...
%>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jun 2 '06 #11

P: n/a
Finally found the problem. I hadn't placed an expires=-1 on the pages.
Didn't think it was necessary. However, the site was being run through a
proxy server which, of course, was caching the page. Mental note to oneself,
if using session variables, use expires=-1 as well!!

Thanks all, for your input.

Martin
"Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote in message
news:em**************@TK2MSFTNGP05.phx.gbl...
Thanks Mike. No I haven't but only as they use Session variables for
various security checks etc and have therefore assumed (cough) that that
side would be OK. I'll double check though.

It may be that this is not really an ASP problem but an IIS problem and is
being visualised as a session variable issue.

Martin
"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11*********************@h76g2000cwa.googlegro ups.com...
Ermmmm.... this might be a silly question, but have you checked to see
if Enable Session State has been checked in the Application
configuration on your client's server?

--
Mike Brind

Martin Walke wrote:
Thanks for the responses guys.

OK.. maybe I'm confused about session variables. My site opens in a new
window from a link. I have a line

<%
...
session("qid") = 0
...
%>
that is on the first page of my site. This session variable is used to
determine what information is to be shown on the next page. The next
page
increments this session variable and after user interaction, the page is
shown again (but with different info) based on the value of 'qid'.

<%
...
session("qid") = session("qid") + 1
...
%>

If the user then quits this site (but doesn't close all browser windows)
and
then returns to the site, the session variable is not reset to 0 on the
first page.

The real rub here is that it works on 3 other servers, plus PWS, but not
on
the client's live server. What gives?

Martin

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:u9**************@TK2MSFTNGP03.phx.gbl...
> Bob Barrows [MVP] wrote:
>> Unless you close all browser windows that were open when
>> the session was begun, you will not get a new session.
>
> Well, that's not entirely true. You ought to get a new one after
> Session.Abandon().
>
>
>
> --
> Dave Anderson
>
> Unsolicited commercial email will be read at a cost of $500 per
> message.
> Use of this email address implies consent to these terms.
>


Jun 5 '06 #12

P: n/a
Martin Walke wrote on 05 jun 2006 in
microsoft.public.inetserver.asp.general:
Finally found the problem. I hadn't placed an expires=-1 on the pages.
Didn't think it was necessary. However, the site was being run through
a proxy server which, of course, was caching the page.
Why not expires = -100 ?

If the client GMT is 2 minutes off, the effective timeout is +1 minute.

True, gugus?
Mental note to
oneself, if using session variables, use expires=-1 as well!!


Only if the session variables are not all session static in their value.

If the sesson variable only shows the login name, it isn't changing
throughout the session once set.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 5 '06 #13

P: n/a

"Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Finally found the problem. I hadn't placed an expires=-1 on the pages.
Didn't think it was necessary. However, the site was being run through a
proxy server which, of course, was caching the page. Mental note to oneself, if using session variables, use expires=-1 as well!!

You are correct that Expires shouldn't be necessary since ASP doesn't
generate cacheable content.

So either your ASP is generating headers which makes the proxy server think
the content is cacheable or
the proxy server is making 'intelligent' choices about whether to cache what
strictly speaking it shouldn't.

For example if your ASP page generates the exact same content every time for
a given request a proxy server might assume that it can safely cache the
response.

For belts and braces prevention of caching use:-

Response.Expires = -1440 ' 1 day old
Response.CacheControl = "private, no-cache, max-age=0" 'Only works with
HTTP/1.1 compliant proxies

Anthony
Thanks all, for your input.

Martin
"Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote in message
news:em**************@TK2MSFTNGP05.phx.gbl...
Thanks Mike. No I haven't but only as they use Session variables for
various security checks etc and have therefore assumed (cough) that that
side would be OK. I'll double check though.

It may be that this is not really an ASP problem but an IIS problem and is being visualised as a session variable issue.

Martin
"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11*********************@h76g2000cwa.googlegro ups.com...
Ermmmm.... this might be a silly question, but have you checked to see
if Enable Session State has been checked in the Application
configuration on your client's server?

--
Mike Brind

Martin Walke wrote:
Thanks for the responses guys.

OK.. maybe I'm confused about session variables. My site opens in a new window from a link. I have a line

<%
...
session("qid") = 0
...
%>
that is on the first page of my site. This session variable is used to
determine what information is to be shown on the next page. The next
page
increments this session variable and after user interaction, the page is shown again (but with different info) based on the value of 'qid'.

<%
...
session("qid") = session("qid") + 1
...
%>

If the user then quits this site (but doesn't close all browser windows) and
then returns to the site, the session variable is not reset to 0 on the first page.

The real rub here is that it works on 3 other servers, plus PWS, but not on
the client's live server. What gives?

Martin

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:u9**************@TK2MSFTNGP03.phx.gbl...
> Bob Barrows [MVP] wrote:
>> Unless you close all browser windows that were open when
>> the session was begun, you will not get a new session.
>
> Well, that's not entirely true. You ought to get a new one after
> Session.Abandon().
>
>
>
> --
> Dave Anderson
>
> Unsolicited commercial email will be read at a cost of $500 per
> message.
> Use of this email address implies consent to these terms.
>



Jun 5 '06 #14

P: n/a
Thanks Anthony and Evertjan. All your comments make good sense and are
appreciated.

Martin
"Anthony Jones" <An*@yadayadayada.com> wrote in message
news:ul**************@TK2MSFTNGP04.phx.gbl...

"Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Finally found the problem. I hadn't placed an expires=-1 on the pages.
Didn't think it was necessary. However, the site was being run through a
proxy server which, of course, was caching the page. Mental note to

oneself,
if using session variables, use expires=-1 as well!!


You are correct that Expires shouldn't be necessary since ASP doesn't
generate cacheable content.

So either your ASP is generating headers which makes the proxy server
think
the content is cacheable or
the proxy server is making 'intelligent' choices about whether to cache
what
strictly speaking it shouldn't.

For example if your ASP page generates the exact same content every time
for
a given request a proxy server might assume that it can safely cache the
response.

For belts and braces prevention of caching use:-

Response.Expires = -1440 ' 1 day old
Response.CacheControl = "private, no-cache, max-age=0" 'Only works with
HTTP/1.1 compliant proxies

Anthony
Thanks all, for your input.

Martin
"Martin Walke" <martin.walke_no_spam@vega_dot_co_dot_uk> wrote in message
news:em**************@TK2MSFTNGP05.phx.gbl...
> Thanks Mike. No I haven't but only as they use Session variables for
> various security checks etc and have therefore assumed (cough) that
> that
> side would be OK. I'll double check though.
>
> It may be that this is not really an ASP problem but an IIS problem and is > being visualised as a session variable issue.
>
> Martin
>
>
> "Mike Brind" <pa*******@hotmail.com> wrote in message
> news:11*********************@h76g2000cwa.googlegro ups.com...
>> Ermmmm.... this might be a silly question, but have you checked to see
>> if Enable Session State has been checked in the Application
>> configuration on your client's server?
>>
>> --
>> Mike Brind
>>
>> Martin Walke wrote:
>>> Thanks for the responses guys.
>>>
>>> OK.. maybe I'm confused about session variables. My site opens in a new >>> window from a link. I have a line
>>>
>>> <%
>>> ...
>>> session("qid") = 0
>>> ...
>>> %>
>>> that is on the first page of my site. This session variable is used
>>> to
>>> determine what information is to be shown on the next page. The next
>>> page
>>> increments this session variable and after user interaction, the page is >>> shown again (but with different info) based on the value of 'qid'.
>>>
>>> <%
>>> ...
>>> session("qid") = session("qid") + 1
>>> ...
>>> %>
>>>
>>> If the user then quits this site (but doesn't close all browser windows) >>> and
>>> then returns to the site, the session variable is not reset to 0 on the >>> first page.
>>>
>>> The real rub here is that it works on 3 other servers, plus PWS, but not >>> on
>>> the client's live server. What gives?
>>>
>>> Martin
>>>
>>> "Dave Anderson" <GT**********@spammotel.com> wrote in message
>>> news:u9**************@TK2MSFTNGP03.phx.gbl...
>>> > Bob Barrows [MVP] wrote:
>>> >> Unless you close all browser windows that were open when
>>> >> the session was begun, you will not get a new session.
>>> >
>>> > Well, that's not entirely true. You ought to get a new one after
>>> > Session.Abandon().
>>> >
>>> >
>>> >
>>> > --
>>> > Dave Anderson
>>> >
>>> > Unsolicited commercial email will be read at a cost of $500 per
>>> > message.
>>> > Use of this email address implies consent to these terms.
>>> >
>>
>
>



Jun 9 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.