Does session cookie persist when after session times out?

G

Guest

I am trying to find storage mechanism that will store a variable until the browser window is closed. A query string variable would be my first choice for this but that is not easily done in my situation. Would a session cookie do the trick? From what I have read, it is persistent until the browser window closes. Is that correct? Even if the session expires, will the session cookie be available when the user continues using the application?

Thanks for your help

Earl
 
R

Raterus

A session cookie and a regular cookie aren't anything different as far as the browser is concerned. But yes, if you set a cookie, without an expiration date, it will remain in the browser until you close it.
 
M

Mike Newton

Earl said:
I am trying to find storage mechanism that will store a variable until the browser window is closed. A query string variable would be my first choice for this but that is not easily done in my situation. Would a session cookie do the trick? From what I have read, it is persistent until the browser window closes. Is that correct? Even if the session expires, will the session cookie be available when the user continues using the application?

Thanks for your help

Earl

I think that the session references a cookie by a particular ID that the
session has. If the session times out, a new one is created with a
different ID. The cookie will still be on the local machine, but the
new session won't be aware of it.

It's better to store variables in cookies (if you want), using
Response.Cookies. This will write a cookie with your own key, which you
can reference for as long as the user or browser keeps it around.

When I use a Session state variable (usually a settings object of some
sort), I store an identifier for that variable in a cookie. If the
session times out, I lose the object, but I can easily rebuild it using
the cookie's data.
 

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

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top