Session variables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I see Session variables time out after 20 minutes (or whatever number of minutes you define)
I want to have some variables that won't time out, but they only occupy very small amounts of data, say 10-20 bytes per user, so I think it won't too much of a performance impact to store it in the web server's memory. Would having hash tables as global variables using the SessionID as key work OK? Global variables and SessionIDs don't time out do they?
 
Hi,

Basically I see two options:
1- Use application variables, with a Hashtable and the userID is the key.
2- Use a class with a static Hashtable or similar struct. it will be global
to the application therefore will not expire with the section.

Please note that both solutions assume that you are doing this for
registered users, if you allow anonymous users and treat each session as a
different user you have to do something else.


Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Bonj said:
I see Session variables time out after 20 minutes (or whatever number of minutes you define).
I want to have some variables that won't time out, but they only occupy
very small amounts of data, say 10-20 bytes per user, so I think it won't
too much of a performance impact to store it in the web server's memory.
Would having hash tables as global variables using the SessionID as key work
OK? Global variables and SessionIDs don't time out do they?
 
Bonj said:
I see Session variables time out after 20 minutes (or whatever number of minutes you define).
I want to have some variables that won't time out, but they only occupy very small amounts of data, say 10-20 bytes per user, so I
think it won't too much of a performance impact to store it in the web server's memory. Would having hash tables as global variables
using the SessionID as key work OK? Global variables and SessionIDs don't time out do they?

It's not the session *variables* that time out, it's the *session* that will
be removed (along with all stored values) after the user has done
nothing (=no new page request) for 20 minutes.

How long do you want to keep this data? Could you store it in
a database?

Hans Kesting
 
Hi
another way you can do it , it to store this in the application variable of
your asp.net and use the session ID as the string that you save the
variable with
so you save this way

Application.Add(session_ID,yourdata_you_want_to_save);
and get the data this way
object whatever = Application.Get(session_ID);
hope this helps .
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 
All Session variables expires after 20 (or x minutes you choose) whatever
type they have, also the corresponding SessionID of the expired Session. Use
Application variables to store common variables.


--
Horatiu Ripa

Bonj said:
I see Session variables time out after 20 minutes (or whatever number of minutes you define).
I want to have some variables that won't time out, but they only occupy
very small amounts of data, say 10-20 bytes per user, so I think it won't
too much of a performance impact to store it in the web server's memory.
Would having hash tables as global variables using the SessionID as key work
OK? Global variables and SessionIDs don't time out do they?
 
You could also look at storing this data in an encrypted cookie. Then you
can set the timeout to whatever you wish with no server overhead.
-mike
MVP
 

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

Back
Top