Skip to content

Sessions Configuration

NOTE: All Magento stores are required to use either Redis or Memcache (recommended) for session storage. We do not allow sessions to be stored in files nor in the database. See Magento Requirements for the full list of requirements.

Redis

You can enable/disable the redis session container under Redis->Session.

hostname: redis-session port: 6380

To view: redis-cli -h redis-session info | tail -4

You can flush redis sessions via CLI with: redis-cli -h redis-session -p 6380 FLUSHALL

Magento 1

Edit your session block in local.xml to enable Redis sessions on your Magento 1 store. Note: In order to use Redis for sessions you must enable the Cm_RedisSession module by opening app/etc/modules/Cm_RedisSession.xml and changing false to true Please note, if this file does not exist you MUST install the module otherwise Redis will not function for sessions on your store.

<session_save>db</session_save>
<redis_session>                     
<host>redis-session</host>          
<port>6380</port>
<password></password>          
<timeout>2.5</timeout>         
<persistent></persistent>       
<db>0</db>                      
<compression_threshold>2048</compression_threshold>
<compression_lib>gzip</compression_lib>            
<log_level>1</log_level>             
<max_concurrency>20</max_concurrency>              
<break_after_frontend>5</break_after_frontend>    
<fail_after>10</fail_after>                        
<break_after_adminhtml>30</break_after_adminhtml>
<first_lifetime>600</first_lifetime>               
<bot_first_lifetime>60</bot_first_lifetime>       
<bot_lifetime>7200</bot_lifetime>                  
<disable_locking>1</disable_locking>              
<min_lifetime>60</min_lifetime>                    
<max_lifetime>2592000</max_lifetime>               
</redis_session>

Magento 2

php bin/magento setup:config:set --session-save=redis --session-save-redis-host=redis-session --session-save-redis-log-level=3 --session-save-redis-db=0 --session-save-redis-port=6380

or

Edit your session block in env.php to enable Redis sessions on your Magento 2 store.

'session' =>
array (
  'save' => 'redis',
  'redis' =>
  array (
    'host' => 'redis-session',
    'port' => '6380',
    'password' => '',
    'timeout' => '2.5',
    'persistent_identifier' => '',
    'database' => '0',
    'compression_threshold' => '2048',
    'compression_library' => 'gzip',
    'log_level' => '1',
    'max_concurrency' => '20',
    'break_after_frontend' => '5',
    'break_after_adminhtml' => '30',
    'first_lifetime' => '600',
    'bot_first_lifetime' => '60',
    'bot_lifetime' => '7200',
    'disable_locking' => '1',
    'min_lifetime' => '60',
    'max_lifetime' => '2592000'
  )
),

Memcache

Magento 1

Edit your session block in local.xml to enable Memcache sessions on your Magento 1 store. ( PHP 5.6 )

<session_save><![CDATA[memcache]]></session_save>
<session_save_path><![CDATA[tcp://memcache:11211?persistent=0&weight=2&timeout=60&retry_interval=10]]></session_save_path>

If you are using PHP 7.0 or higher with Magento 1, please use the following instead.

<session_save><![CDATA[memcached]]></session_save>
<session_save_path><![CDATA[memcache:11211?persistent=0&weight=2&timeout=60&retry_interval=10]]></session_save_path>

Magento2

Edit your session block in env.php to enable Memcache sessions on your Magento 2 store.

'session' =>
   array (
      'save' => 'memcache',
      'save_path' => 'tcp://memcache:11211'
),

For Magento version 2.3+, add the following under PHP -> OPTIONS

session.save_handler=memcache
session.save_path=memcache:11211