Earl Teigrob wrote:
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.