Session Confusion

G

Guest

BackGround:
- We are new to ASP
- We thought we would experiment with using the session object (in proc) to store a small amount of data.
- We get different results when cookieless is set to "true" veses "false".
- Our simple test app involved updating a counter that was stored as an item in the Session Object. We allow resetting the counter to zero, and adding or subtracting one from the counter.
- We were trying to determine when a "NEW Session" is created -- so we kept in our App adding and resetting and subtracting. After each we displayed the values and everything worked fine. When the user entered a URL for a different site (Goggle.com) and then entered the URL for our page -- initially we see that the counter was reset to zero through our logic in the "Page_Load" routine for a new session.
- When using Session option of Cookieless = 'false', when we do an add it picks up the previous Counter Value that was used before we went to the other Web site (Goggle.com). This is confusing because we use the Session Counter field to display the Counter when 1st returning to this page and it displays a value of Zero. We also noticed that the Session ID does not change but "Session.IsNewSession" property is set to True.
- When using Session option of Cookieless = 'true', when we do an add it picks up the new initialized Counter Value (Zero) that was set in "Page_Load" after returning from the Web site (Goggle.com). In this case we see a new SessionID and the "Session.IsNewSession" property is set to True.

If you would like to see this in action where "SessionState" cookieless option ="false" you can use the following link.

http://www.hoffmanngroupservices.com/SimpleSessionTest/SSTHomePage.aspx

Thanks
Dinkster
 
A

Alvin Bruney

Please read this to understand what is going on with session and how new
requests affect it.
http://tinyurl.com/2t7gq

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Dinkster said:
BackGround:
- We are new to ASP
- We thought we would experiment with using the session object (in
proc) to store a small amount of data.
- We get different results when cookieless is set to "true" veses "false".
- Our simple test app involved updating a counter that was stored as an
item in the Session Object. We allow resetting the counter to zero, and
adding or subtracting one from the counter.
- We were trying to determine when a "NEW Session" is created -- so we
kept in our App adding and resetting and subtracting. After each we
displayed the values and everything worked fine. When the user entered a
URL for a different site (Goggle.com) and then entered the URL for our
page -- initially we see that the counter was reset to zero through our
logic in the "Page_Load" routine for a new session.
- When using Session option of Cookieless = 'false', when we do an add
it picks up the previous Counter Value that was used before we went to the
other Web site (Goggle.com). This is confusing because we use the Session
Counter field to display the Counter when 1st returning to this page and it
displays a value of Zero. We also noticed that the Session ID does not
change but "Session.IsNewSession" property is set to True.
- When using Session option of Cookieless = 'true', when we do an add
it picks up the new initialized Counter Value (Zero) that was set in
"Page_Load" after returning from the Web site (Goggle.com). In this case we
see a new SessionID and the "Session.IsNewSession" property is set to True.
If you would like to see this in action where "SessionState" cookieless
option ="false" you can use the following link.
 
S

Shiv Kumar

Dinkster,

You need to probably better understand how browsers treat cookies in order
to better understand ASP.NET sessions (cookieless=false). Primarily there
are two types of cookies. Those that get saved on the hard drive somewhere
and those that are not. The second variety are called session cookies. These
have nothing to do with ASP/ASP.NET sessions but actually to do with a
browser session. Session cookies are valid/available till a browser session
is active. In other words, till as long as the browser instance is not
closed, the session cookie (once set) is available. Once the browser is
closed, the session cookie is gone (that is, the browser session has ended).

ASP.NET creates these kind of cookies (browser session cookies). As a result
you see the behavior you see. That is, even if you go to another website and
come back, the ASP.NET session is still "alive" (provided the session
timeout has not elapsed). This explanation should clear your confusion.

As regards "new" sessions etc. you might want to use the global.asax file
with various events for when sessions start, end etc. Using these events are
probably a better way to hook into starting and ending of sessions.
 

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

Top