Increase the customer session on the website

The timeout occurring at short intervals was due to security measures triggered by user inactivity. 

To improve the same,

For frontend (customer) sessions:

  1. Go to Stores > Configuration.
  2. Navigate to General > Web.
  3. Under Default Cookie Settings, adjust:
  • Cookie Lifetime: Enter the number of seconds for the session duration (e.g., 86400 for 24 hours).
  1. Click Save Config and clear the cache.

3. Change in env.php (Optional):

You can also define session lifetime directly in the env.php file:

  1. Open app/etc/env.php.
  2. Add or modify the following:
php

Copy

Edit
'session' => [
    'save' => 'files',
    'cookie_lifetime' => 86400, // 24 hours
    'gc_maxlifetime' => 86400,  // 24 hours
],
  1. Save the file and clear the cache:

php bin/magento cache:flush

Leave a comment

Your email address will not be published. Required fields are marked *