Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where does session save?

I would like to know where PHP session data is saved; is it in client browser? or on the server?

When I disable cookies in my browser setting, PHP can't save session data, but in php.ini, I can change the session save path.

Is session data stored on the server or client browser?

like image 222
Moein Hosseini Avatar asked Apr 08 '11 09:04

Moein Hosseini


People also ask

What is session and where it is stored?

A session is a global variable stored on the server. Each session is assigned a unique id which is used to retrieve stored values. Whenever a session is created, a cookie containing the unique session id is stored on the user's computer and returned with every request to the server.

Where are session cookies stored?

The session cookie is stored in temporary memory and is not retained after the browser is closed. Session cookies do not collect information from your computer. They typically store information in the form of a session identification that does not personally identify the user.

Is session stored in browser?

To track sessions, a web session ID is stored in a visitor's browser. This session ID is passed along with any HTTP requests that the visitor makes while on the site (e.g., clicking a link). “Session” is the term used to refer to a visitor's time browsing a web site.

What is session save path?

session_save_path() returns the path of the current directory used to save session data.


1 Answers

The session data that you read and write using $_SESSION is stored on server side, usually in text files in a temporary directory. They can not be accessed from outside.

The thing connecting a session to a client browser is the session ID, which is usually stored in a cookie (see the comments for exceptions to that rule). This ID is, and should be, the only thing about your session that is stored on client side.

If you delete the cookie in the browser, the connection to that session is lost, even if the file on the server continues to exist for some time.

The session.save_path variable influences the location on the server where the session data is stored. If you are not the server's administrator, it is usually not necessary to change it.

like image 121
Pekka Avatar answered Oct 14 '22 12:10

Pekka