473,785 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Non-persistent" session variables

Dear ASP community,

I have a question regarding ASP session variables.

My assumption was that a session variable has the same lifetime as the
session itself: as a consequence, given that closing the browser doesn't
terminate the session, the session variable is kept alive until the
session expires.

But, surprisingly, I've found this to be true for the session variables
whose value is set in the global.asa file, but if the value is set in an
..asp script, it appears to be erased from the session object as soon as
the browser is closed although the session is still alive. Strange. Is
this a bug?

What I'd need to know is: how I can make session variables whose value
is set in an .asp script persistent as long as the session is alive.

Thank you for your help,

A. S.
Oct 23 '06 #1
3 2125
Arnost Sobota wrote:
Dear ASP community,

I have a question regarding ASP session variables.

My assumption was that a session variable has the same lifetime as the
session itself: as a consequence, given that closing the browser
doesn't terminate the session, the session variable is kept alive
until the session expires.

But, surprisingly, I've found this to be true for the session
variables whose value is set in the global.asa file, but if the value
is set in an .asp script, it appears to be erased from the session
object as soon as the browser is closed although the session is still
alive. Strange. Is this a bug?
No. It's impossible. The server has no way of knowing the browser has
been closed.

Of course, once you close the browser, you have no way to access the
values set in the previous session (opening a new browser window
initiates a new session), so how are you determining that the values are
being erased when the browser window is closed?

Provide a repro script we can run to exhibit the behavior you are
seeing.

--
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.
Oct 23 '06 #2
Bob Barrows [MVP] a écrit :
Arnost Sobota wrote:
>Dear ASP community,

I have a question regarding ASP session variables.

My assumption was that a session variable has the same lifetime as the
session itself: as a consequence, given that closing the browser
doesn't terminate the session, the session variable is kept alive
until the session expires.

But, surprisingly, I've found this to be true for the session
variables whose value is set in the global.asa file, but if the value
is set in an .asp script, it appears to be erased from the session
object as soon as the browser is closed although the session is still
alive. Strange. Is this a bug?

No. It's impossible. The server has no way of knowing the browser has
been closed.

Of course, once you close the browser, you have no way to access the
values set in the previous session (opening a new browser window
initiates a new session), so how are you determining that the values are
being erased when the browser window is closed?

Provide a repro script we can run to exhibit the behavior you are
seeing.
Bob,
Silly me! Of course you're one-hundred-percent right! I simply forgot
that opening a new browser window initiates a new session and that there
is no way to access the session variables from another session.

A. S.
Oct 23 '06 #3
Are you sure they are kept ? IMO the code you have in global.asa (usally in
the session start event) just creates them again so when you browse the site
they always appears there (not because they are kept but because you have
created them again). Store also the SessionID or the current datetime and
you should see this is not the same value.

Else give some more details about how they are created (in global.asa, which
event, how (in case it would be a confusion between static application
scoped variable declared with the object tag and session variables).

When you close/reopens the browser, the session is kept on the server but he
server will create a new session if you reconnect (the temporary cookie used
for sessions is stored in memory and is deleted when the browser is closed).

--
Patrice

"Arnost Sobota" <sa******@minef i.gouv.fra écrit dans le message de news:
45************* **********@news .orange.fr...
Dear ASP community,

I have a question regarding ASP session variables.

My assumption was that a session variable has the same lifetime as the
session itself: as a consequence, given that closing the browser doesn't
terminate the session, the session variable is kept alive until the
session expires.

But, surprisingly, I've found this to be true for the session variables
whose value is set in the global.asa file, but if the value is set in an
.asp script, it appears to be erased from the session object as soon as
the browser is closed although the session is still alive. Strange. Is
this a bug?

What I'd need to know is: how I can make session variables whose value is
set in an .asp script persistent as long as the session is alive.

Thank you for your help,

A. S.

Oct 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3756
by: Adrian Parker | last post by:
For some reason when I call validateFields before .Update (see below), I get this error: "Consumer's even handler called a non-reentrant method in the provider" However if I comment out the call to validateFields, all is fine. What could possibly cause this error? What is a non-reentrant method?
14
2710
by: mirnazim | last post by:
Hi, There are great Python Web Application Framework. But most of them are meant for content oriented web apps. Is there something that can ease the development of application that are not content oriented(I call them "NON CONTENT-ORIENTED WEB APPLICATIONS" because I don't know what else to call them). I mean the applications like, accounting, high volume data entry apps, where normally GUI clients have ruled. I know very high...
1
2130
by: JKop | last post by:
Would you classify the following code as "Undefined Behaviour" or as "Non- portable"? signed main() { signed char chedder = 130; } Relevant information:
15
2851
by: Sander Tekelenburg | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The HTML specs speak of "replaced" and "non-replaced" elements, yet for the life of me I can't find an explanation of what "replaced" is supposed to mean in this context. Can someone explain? TIA
8
3516
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I cannot load/unload/reload extensions into my large and slow-to-load application during development without restarting the process then the disadvantages may outweigh the advantages. I've got a mixed-mode program in which I create a new AppDomain...
2
1996
by: thorax | last post by:
I'm having problems running a release build of an application. The application is a native C++ .NET 2003 MFC application which links to a number of other DLLs, one of which is mixed (SLGSE.dll) (VB.NET/C++). Most of the DLLS are statically linked to the main exe (directly or indirectly) but a few are dynamically linked at runtime. When I try and run the app, it gets "An unhandled non- continuable exception was thrown during process...
7
10302
by: Benton | last post by:
Hi there, I have a text box which will receive its value from a pop-up date picker. The user should not be able to edit this field with the keyboard or mouse. I am using ASP.NET. If I set the readonly property of the textbox to true, it won't let the user change it and it can receive its value from the pop-op calendar, just what I need. Problem is, after a postback, value is lost. So I think Javascript may come to the rescue here. Is...
3
1485
by: Pierre Barbier de Reuille | last post by:
Hi, after reading the article " The Standard Librarian : Defining Iterators and Const Iterators" from Matt Austern: http://www.ddj.com/showArticle.jhtml;jsessionid=41JODBZDWEMBYQSNDLOSKH0CJUNN2JVN?articleID=184401331 I wanted to test using the non-template function friends of template classes. So I devised this code: ===8<======8<======8<======8<======8<======8<======8<===
1
2494
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I have Mobile site that I'm building. My problem is that all of my pages are built as Mobile ASPX pages, but occasionally, I need to use controls which are not mobile. Most specifically, the "FileUpload" control. Now, most phones don't support this feature, but some do and for them I need to place and use this control. How can I insert a FileUpload control on a Mobile ASPX? Alex
10
1911
by: Jason Doucette | last post by:
Situation: I have a simple struct that, say, holds a color (R, G, and B). I created my own constructors to ease its creation. As a result, I lose the default constructor. I dislike this, but it's easy to solve: I just make my own default constructor. Problem: My own default constructor is considered to be *initializing the variable* (even though it doesn't), whereas the original one does not. Thus, when I declare and use it before...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8978
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.