Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > "Non-persistent" session variables

Reply
Thread Tools

"Non-persistent" session variables

 
 
Arnost Sobota
Guest
Posts: n/a
 
      10-23-2006
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.
 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      10-23-2006
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.


 
Reply With Quote
 
 
 
 
Arnost Sobota
Guest
Posts: n/a
 
      10-23-2006
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.
 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      10-23-2006
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" <(E-Mail Removed)> a écrit dans le message de news:
453cc7c2$0$25913$(E-Mail Removed)...
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Session Variables and Static Variables cobus.lombard@gmail.com ASP .Net 1 03-26-2006 11:05 AM
RE: Session Variables assigned to the wrong session? Robert Faulkner ASP .Net 0 01-28-2005 04:16 PM
Session Variables assigned to the wrong session? =?iso-8859-15?Q?Fabr=EDcio_de_Novaes_Kucinskis?= ASP .Net 1 01-20-2005 04:33 PM
Global Session Variables and Session State Earl Teigrob ASP .Net 1 12-17-2003 07:02 AM



Advertisments