The timeout occurring at short intervals was due to security measures triggered by user inactivity.
To improve the same,
For frontend (customer) sessions:
- Go to Stores > Configuration.
- Navigate to General > Web.
- Under Default Cookie Settings, adjust:
- Cookie Lifetime: Enter the number of seconds for the session duration (e.g., 86400 for 24 hours).
- 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:
- Open
app/etc/env.php. - Add or modify the following:
php
Copy
Edit
'session' => [
'save' => 'files',
'cookie_lifetime' => 86400, // 24 hours
'gc_maxlifetime' => 86400, // 24 hours
],
- Save the file and clear the cache:
php bin/magento cache:flush