Aug 15, 2011

Store session files in different directories in PHP


I have several sites hosted on the same server, in different directories (e.g:, and I want to store the session files for each site in a different directory.
How do I do that?



If you’re running PHP as an Apache2 module, the following should work for you.

In the folder you want to change the session path (e.g, create a .htaccess file with the following in it:
php_value session.save_path "/path/to/separate/sessions/site_one".

Repeat this and change the directory for each folder you want to have a separate session path.

Related posts:

  1. PHP Session File Stored in Temp Directory – Apache
  2. Stopping PHP ability to read/write other PHP files
  3. Format Filename for Process Core Files per Session
  4. Change ownership or permissions on only directories or files, recursively
  5. What is creating session files?

Leave a comment