Where is a PHP session file stored?

I have read about files related to $_SESSION, but I would like to find them. Where are they stored?

Author: UzumakiArtanis, 2017-09-25

2 answers

The storage location of the variable $ _SESSION is determined by the configuration session.save_path from PHP. Typically, the path is /tmp on a Linux/Unix system.

Use the function phpinfo() to see your settings if you are not 100% sure of the location. Just create a .php file with this code in your domain's DocumentRoot:

<?php
   phpinfo();
?>

Note

As said in the comments, and also very important to point out:

Form simplified, you can use the session_save_path() that controls that directive.

If you use session_save_path() you can easily find out the location of the storage of session variables:

<?php
    echo session_save_path();
?>

We also have an answered question about this in our Big Brother SO.

 5
Author: UzumakiArtanis, 2020-06-11 14:45:34

On the server, of course, it would not make sense to keep this control on the client, this information is necessary precisely for the application to maintain some state between requests.

 1
Author: Maniero, 2017-09-25 14:35:28