Adobe Commerce 2.3 reached end of support in September 2022.

How to locate your session files

Locate your session storage

This topic discusses how to locate where your session files are stored. The system uses the following logic to store session files:

  • If you configured memcached, sessions are stored in RAM; for more information, see Use memcached for session storage.
  • If you configured Redis, sessions are stored on the Redis server; for more information, see Use Redis for page caching or session storage.
  • If you’re using the default file-based session storage, we store sessions in the following locations in the order shown:

    1. Directory defined in env.php
    2. Directory defined in php.ini
    3. <magento_root>/var/session directory

env.php example

A sample snippet from <magento_root>/app/etc/env.php follows:

1
2
3
4
5
 'session' =>
    array (
      'save' => 'files',
      'save_path' => '/var/www/session',
 ),

The preceding example stores session files in /var/www/session

php.ini example

As a user with root privileges, open your php.ini file and search for the value of session.save_path. This identifies where sessions are stored.

Manage session size

See the User Guide.

Garbage collection configuration

To clean up expired sessions, the system calls the gc (garbage collection) handler randomly according to a probability that is calculated by the gc_probability / gc_divisor directive. For example, if you set these directives to 1/100 respectively, it means a probability of 1% (probability of one call of garbage collection per 100 requests).

The garbage collection handler uses the gc_maxlifetime directive—the number of seconds after which the sessions will be seen as garbage and potentially cleaned up.

On some operating systems (Debian/Ubuntu), the default session.gc_probability directive is 0, which prevents the garbage collection handler from running.

You can overwrite the session.gc_ directives from the php.ini file in the <magento_root>/app/etc/env.php file:

1
2
3
4
5
6
7
 'session' =>
    array (
      'save' => 'db',
      'gc_probability' => 1,
      'gc_divisor' => 1000,
      'gc_maxlifetime' => 1440
 ),

The configuration varies, depending on the traffic and specific needs of the merchant’s website.