473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

The existance of session variables

Hi,
I was wondering how long the created session variables last for?

To be more clear, when are they destroyed? Do I have to set the variables to
null in Session_End()? Is the Session_End() method invoked when the browser
is closed?

I'm just not sure how it works.

Thanks in advance,

Tim.
Nov 18 '05 #1
4 1178
By default session variables expire 20 minutes since last page access. (You
can set this in web.config)

Session_End() is NOT invoked when the browser is closed.

Greg

"Timothy V" <tr****@msn.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Hi,
I was wondering how long the created session variables last for?

To be more clear, when are they destroyed? Do I have to set the variables to null in Session_End()? Is the Session_End() method invoked when the browser is closed?

I'm just not sure how it works.

Thanks in advance,

Tim.

Nov 18 '05 #2
Hi just started using session variables, no expert but this is what I have seen so far.
Session variables exist from when the web application is started until it is ended.
It is started when the browser of the user opens the start page and ends when the user no longer has any page open from the application. Session variables are visible to all pages of the application when invoked.
--
Paul G
Software engineer.
"Timothy V" wrote:
Hi,
I was wondering how long the created session variables last for?

To be more clear, when are they destroyed? Do I have to set the variables to
null in Session_End()? Is the Session_End() method invoked when the browser
is closed?

I'm just not sure how it works.

Thanks in advance,

Tim.

Nov 18 '05 #3
If only that were true!

You need to be very careful. Say you have a session variable
session("username")="greg". If the users walks away from the machine and
comes back 20+ minutes later and causes a postback on your page a new
session will start.

When you go to access your session("username") variable that you thought was
populated you'll get an exception because it will be now equal to nothing!

This scenario has caused me many many headaches. ;(

You can/should always check your session variables for nothing before using
them. Same will Cache items, cause those can be purged at any point in time.

PS: If anybody has ever figured at a full proof way of displaying a session
expired page while using forms authentication, I would love to hear it!

Greg

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:18**********************************@microsof t.com...
Hi just started using session variables, no expert but this is what I have seen so far. Session variables exist from when the web application is started until it is ended. It is started when the browser of the user opens the start page and ends when the user no longer has any page open from the application. Session
variables are visible to all pages of the application when invoked. --
Paul G
Software engineer.
"Timothy V" wrote:
Hi,
I was wondering how long the created session variables last for?

To be more clear, when are they destroyed? Do I have to set the variables to null in Session_End()? Is the Session_End() method invoked when the browser is closed?

I'm just not sure how it works.

Thanks in advance,

Tim.

Nov 18 '05 #4
for further reading
http://support.microsoft.com/default...b;en-us;555082

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:18**********************************@microsof t.com...
Hi just started using session variables, no expert but this is what I have
seen so far.
Session variables exist from when the web application is started until it
is ended.
It is started when the browser of the user opens the start page and ends
when the user no longer has any page open from the application. Session
variables are visible to all pages of the application when invoked.
--
Paul G
Software engineer.
"Timothy V" wrote:
Hi,
I was wondering how long the created session variables last for?

To be more clear, when are they destroyed? Do I have to set the variables
to
null in Session_End()? Is the Session_End() method invoked when the
browser
is closed?

I'm just not sure how it works.

Thanks in advance,

Tim.

Nov 18 '05 #5

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

Similar topics

6
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an...
9
by: Josiah Manson | last post by:
Hello. I am very new to Python, and have been unable to figure out how to check if a variable exists or not. In the following code I have made a kludge that works, but I think that it would be...
6
by: Lina Manjarres | last post by:
Hello, I have a session variable in a login page. Then I go to a form page where I uses the ProfileID and the UserID. Then I go to a result page where I would like to use the UserID as a filter,...
4
by: PJ | last post by:
A particular page seems to be having issues with correctly setting Session variables. I am setting a couple of session variables on the Page_Unload event. While stepping through code, the...
31
by: Harry Simpson | last post by:
I've come from the old ASP camp where session variables were not used. When i started using ASP.NET in 2001, I started using them again because it was ok from what I'd read. I've been merrily...
10
by: tshad | last post by:
I have been using the default session state (InProc) and have found that I have been loosing my information after a period of time (normally 20 minutes). Is there anyway to find out how much...
3
by: Alan Wang | last post by:
Hi there, Once my application gets complicated and complicated. I found it's really hard to keep track of Session value I am using in my asp.net application. I am just wondering if anyone have...
18
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
26
by: BillE | last post by:
Some ASP.NET applications use Session Variables extensively to maintain state. These should be re-written to use viewstate, hidden fields, querystring, etc. instead. This is because if a user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.