Thursday, March 22, 2012

Session Variables

I have a question regarding session variables. I have a stored procedure that runs and grabs a person's jobid and stores it in a session variable. My question is: how is this session variable stored? What happens if two people are trying to access the page. If they have different jobID's, how does it know which session variable to use. When the variable saves on the server, does it have a connection to each computer accessing the server?Session variables are stored in in-process memory on the server. Each connection to the web server gets it own session and is isolated from any other session. Like threads. The session variables are not really "saved" on the server in the literal since.

You can actually have several session and, therefore, several sets of session variables from one computer. Just open another browser and connect to the application and you have another session.

I would not be concerned about how the server keep up with them; just know that you will never see the server give the wrong session variable to the wrong user.

Chad
Sessions are maintained through the use of cookies that hold a unique session id. When a person visits your site (and your site uses sessions), the response from the server will contain a cookie with a new session id that the browser will continue to send throughout the length of the person's visit.

Another user hitting the same page will get a response with a different session id cookie.

This ID is the indexer into the Session information on the server.

0 comments:

Post a Comment