Solved: Failed to Set ini Option “session.cookie_samesite” to Value “Lax” in Magento 2.3.6-p1
Did you try to install Magento 2.3.6-p1?
And faced an error after installing the Magento version 2.3.6-p1 that looks something like this:
report.ERROR: Failed to set ini option “session.cookie_samesite” to value “Lax”.
If yes, relatable!
Because I’ve also faced the same error. To save you from all the process I went through to find the solution to Failed to Set ini Option “session.cookie_samesite” to Value “Lax” in Magento 2.3.6-p1, I have posted it here.
This error occurs due to the lower PHP version you may be using.
Solution for Failed to Set ini Option “session.cookie_samesite” to Value “Lax” in Magento 2.3.6-p1
PHP 7.3 or above version is a must to solve this error!
So check if your version of PHP is 7.3 or above. If not, set PHP 7.3 or above version.
However, I have another solution for this error if you don’t want to change your PHP version.
Use the below code in your SessionManager.php file located at vendor\magento\framework\Session\
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
private function initIniOptions() { $result = ini_set('session.use_only_cookies', '1'); if ($result === false) { $error = error_get_last(); throw new \InvalidArgumentException( sprintf('Failed to set ini option session.use_only_cookies to value 1. %s', $error['message']) ); } foreach ($this->sessionConfig->getOptions() as $option => $value) { if ($option === 'session.cookie_samesite') { continue; } if ($option == 'session.save_handler') { continue; } else { $result = ini_set($option, $value); if ($result === false) { $error = error_get_last(); throw new \InvalidArgumentException( sprintf('Failed to set ini option "%s" to value "%s". %s', $option, $value, $error['message']) ); } } } } |
However, it is not recommended to apply changes in the default file of Magento. So it is better to use PHP version 7.3 or above.
That’s all!
If you have any doubts regarding this error and its solution, just mention them in the Comments section below.
I would be happy to help.
Feel free to share the solution with Magento Community via social media.
Thank You.
Jignesh Parmar
An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.
Prev
How to Get All Product URLs in Magento 2
Solved: Uncaught ReferenceError: Base64 is not Defined in Magento 2.3
Next