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?
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.
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.
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.
session_save_path() returns the path of the current directory used to save session data.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With