Magento 2 Your session has expired

After migrating Magento 2 site to a new server with a different URL, adding an item to the cart produced the error message “Your session has expired”.

First, I verified PHP session is working with a test script

Renamed index.php to index.php.old and created a new index.php file with the above code. Every time I refreshed, I get a new number, which meant PHP session is working. If the number stay same on refresh, PHP session is not working, you need to look at your PHP configuration, and verify the session.save_path settings in php.ini is set properly and is writeable.

Verify URLs are set properly.

If you see wrong URL, update it with the command

Also verify cookie settings, main domain is set properly.

Example

Look for setting web/cookie/cookie_domain, if it is wrong domain, set it to the new domain or leave it empty. In this case, the domain was set to old URL – 5351499f87.nxcli.net

Clear magento cache

Back to Magento

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published.