Magento 2 Cart get empty on page referesh only in Mozila firefox
-
12-12-2020 - |
Question
I am using magento 2.1.7 version. I have upgraded it to 2.1.9 after upgradation it is working fine on google chrome, but on Firefox cart get empty on refresh page or apply coupon code it also get empty.
Solution 2
I have figure it out is is due to session regeneration code in file vendor/magento/framework/Session/SessionManager.php
as below
$oldSessionId = session_id();
session_regenerate_id();
$newSessionId = session_id();
session_id($oldSessionId);
session_destroy();
$oldSession = $_SESSION;
session_id($newSessionId);
session_start();
$_SESSION = $oldSession;
As of now temporary solution replace above code with below code
session_regenerate_id(false);
OTHER TIPS
I've found a work around for this this doesn't require you to make a modification to Magento's code base.
If you change your sessions storage to be DB rather than Files I can no longer recreate the issue.
Change : app/etc/env.php
...
'session' =>
array (
'save' => 'files',
),
...
to
...
'session' =>
array (
'save' => 'db',
),
...
Obviously there are inherent downsides here i.e. writing sessions to the DB can cause the database to bloat, so wouldn't be ideal if you are working with a large catalog.