Session variables

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?
 
I

Ignacio Machin \( .NET/ C# MVP \)

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?
 
H

Hans Kesting

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
 
H

Horatiu Ripa

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?
 
M

Michael Giagnocavo [MVP]

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

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top