PHP Tutorials - Herong's Tutorial Examples - Version 4.18, by Dr. Herong Yang
Where Is Session Data Stored?
This section provides a tutorial example on how to find out where the PHP engine stores session data. The session.save_path setting specifies the directory name for session data.
Where does PHP store session data? The answer is not so obvious.
Since I am running the PHP engine in CGI mode, PHP script pages are running with individual instances of the PHP executable program. So there is no easy to store session data in memory and share it between different PHP script pages. If not stored in memory, session data can be stored on hard disk and share it between PHP pages. Let's see if we can find where session data is stored on the hard disk.
First run http://localhost/SessionPage1.php again:
I am buying 3 PHP books. Next Counter = 1 Session name = PHPSESSID Session id = mg04r204ctuloo2uegmih14ri5 Session module = files Contents of $_GET: Contents of $_POST: Contents of $_COOKIE:
Then use the Windows find tool to search for file names with "mg04r204ctuloo2uegmih14ri5". No surprise, you should get \tmp\sess_mg04r204ctuloo2uegmih14ri5. Open this file in a text editor, you should see:
The file format is so simple, session data is stored in clear text, with ";" as delimiters. If you want to change where session data is stored, you can modify the session.save_path setting in \php\php.ini. For example:
session.save_path = "\herong\temp"
Last update: 2015.
Table of Contents