What is the default location of session files on an installation of Apache/PHP on Ubuntu 10.10?
PHP Session Start By default, session data is stored in the server's /tmp directory in files that are named sess_ followed by a unique alphanumeric string (the session identifier). By itself, the session_start() function doesn't add much functionality to a web page.
PHP - session_save_path() Function Sessions or session handling is a way to make the data available across various pages of a web application. The session_save_path() is used to set or retrieve the path where the current session data is saved.
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.
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 default session.save_path
is set to ""
which will evaluate to your system's temp directory. See this comment at https://bugs.php.net/bug.php?id=26757 stating:
The new default for save_path in upcoming releaess (sic) will be the empty string, which causes the temporary directory to be probed.
You can use sys_get_temp_dir
to return the directory path used for temporary files
To find the current session save path, you can use
session_save_path()
— Get and/or set the current session save pathRefer to this answer to find out what the temp path is when this function returns an empty string.
First check the value of session.save_path
using ini_get('session.save_path')
or phpinfo()
. If that is non-empty, then it will show where the session files are saved. In many scenarios it is empty by default, in which case read on:
On Ubuntu or Debian machines, if session.save_path
is not set, then session files are saved in /var/lib/php5
.
On RHEL and CentOS systems, if session.save_path
is not set, session files will be saved in /var/lib/php/session
I think that if you compile PHP from source, then when session.save_path
is not set, session files will be saved in /tmp
(I have not tested this myself though).
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