Session variables

M

Martin Walke

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
 
B

Bob Barrows [MVP]

Martin said:
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.
 
M

Martin Walke

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
 
B

Bob Barrows [MVP]

Martin said:
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?
 
B

Bob Barrows [MVP]

Martin said:
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.
 
D

Dave Anderson

Bob said:
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().
 
M

Martin Walke

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
 
E

Evertjan.

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
....
%>
 
M

Mike Brind

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?
 
M

Martin Walke

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
 
M

Martin Walke

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
 
M

Martin Walke

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
 
E

Evertjan.

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.
 
A

Anthony Jones

Martin Walke said:
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
 
M

Martin Walke

Thanks Anthony and Evertjan. All your comments make good sense and are
appreciated.

Martin
 

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
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top