Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are the session variables saved?

Where exactly are session variables saved? Cookies? Server memory?

Again where are Application variables saved?

like image 856
Manish Avatar asked Dec 24 '10 12:12

Manish


People also ask

Where Are session variables stored in Java?

Simple answer is : your session data are stored on the server side. Web browser will get only an string id to identify it's session. In fact, spring security takes more care of session information, because if users even don't login, session may not exist at all.

Where does session data get stored in PHP?

PHP Default Session Storage (File System): In PHP, by default session data is stored in files on the server. Each file is named after a cookie that is stored on the client computer. This session cookie (PHPSESSID) presumably survives on the client side until all windows of the browser are closed.

How do I access session variables?

To start PHP sessions, you must use the function session_start() . To set session variables, you will need to apply a global PHP $_SESSION variable . Note: The PHP session_start() function has to be the first thing in your document: all HTML tags come after.

Where is browser session ID stored?

A session variable's content is stored on the server, however, the session is identified by a session ID which is stored at the client and sent with each request. Usually the session ID is stored in a cookie, but it can also be appended to URL's.


3 Answers

Variables put into Session are stored wherever the configured SessionStateProvider is configured to store them.

The default SessionStateProvideruses what's referred to as In Process (InProc) Session and the storage location for this is in server memory, inside the memory space of the ASP.NET worker process.

You can configure your own SessionStateProvider to store Session variables elsewhere, such as out of process, in a database.

Application variables are stored in ApplicationState which is also stored in the memory space of the ASP.NET worker process. Unlike Session State, Application State applies to all users and sessions. As far as I am aware, There is no configuration to store ApplicationState elsewhere; if you need to store lots of application data then you may want to look at ASP.NET Caching.

like image 81
Russ Cam Avatar answered Oct 16 '22 16:10

Russ Cam


Session variables are stored on Server Memory and Disk as Application Variables are.

From ASP.NET documentation:

ASP.NET session state supports several storage options for session variables. Each option is identified as a session-state Mode type. The default behavior is to store session variables in the memory space of the ASP.NET worker process. However, you can also specify that session state should be stored in a separate process, in a SQL Server database, or in a custom data source. If you do not want session state enabled for your application, you can set the session mode to Off.

like image 41
Pablo Santa Cruz Avatar answered Oct 16 '22 16:10

Pablo Santa Cruz


For an InProc session, variables are stored locally in memory of ASP.NET worker process. Same goes for application state.

like image 4
Dienekes Avatar answered Oct 16 '22 18:10

Dienekes