Where does Magento 2 save session files?

According to the documentation, it is possible to save in the database, in redis, in memcache or in files, but in the default installation it looks like this.

'session' => [ 'save' => 'files' ],

I checked the var/session folder and there is nothing, not even in the database (session table).

Does magento save to temp, browser cache, cookie or elsewhere?

How do I identify?

2 Answers 2


Magento 2 utilizes PHP's default session handling mechanism, and the session files are stored in the 'var/session' directory by default. To inspect or configure the session save path, you can refer to the 'app/etc/env.php' file in your Magento installation, specifically in the 'session' configuration section.

It's essential to note that the precise location of session files can be influenced by your server configuration and PHP settings related to session handling. If your Magento 2 installation has a customized session save path, you should examine the corresponding configuration in your environment-specific files.

In our case, we are using the Apache server, and Magento sessions are stored at the following path, which you can verify using phpinfo(). enter image description here

  • So if there is nothing in the env.php configuration, Magento will apply the php default. Thanks. Jan 23 at 16:35
  • Yes @BrunoDepieriBarduchi
    – Msquare
    Jan 24 at 6:58

In <magento_root>/app/etc/env.php

'session' => [
     'save' => 'files',
     'save_path' => '/var/www/session'

If you have not mentioned the save_path as above then it will pickup the session path from php configuration. Yon can find this path from this variable session.save_path which is available in your php.ini

You can also follow this guide: https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/storage/session-storage/sessions.html

Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.