In your website sameite=none is not set on your site. SO By default it is having lax value.
Samesit=Lax having restrictions with get and post data.
You will have to integrate it.
You can try to add as below:
I the file check with change the code app/code/core/Mage/Core/Model/Cookie.php
add code on Line 41
const SAMESITE = ';samesite=none';
And Replace code below on line 240 :
setcookie($name, $value, $expire, $path.self::SAMESITE, $domain, $secure, $httponly);
If It works then override the Core file to local directory.
@Madhu Rajawat Is right what i did,
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Core
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Core cookie model
*
* @category Mage
* @package Mage_Core
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Core_Model_Cookie
{
const XML_PATH_COOKIE_DOMAIN = 'web/cookie/cookie_domain';
const XML_PATH_COOKIE_PATH = 'web/cookie/cookie_path';
const XML_PATH_COOKIE_LIFETIME = 'web/cookie/cookie_lifetime';
const XML_PATH_COOKIE_HTTPONLY = 'web/cookie/cookie_httponly';
const SAMESITE = ';samesite=none';
protected $_lifetime;
/**
* Store object
*
* @var Mage_Core_Model_Store
*/
protected $_store;
/**
* Set Store object
*
* @param mixed $store
* @return Mage_Core_Model_Cookie
*/
public function setStore($store)
{
$this->_store = Mage::app()->getStore($store);
return $this;
}
/**
* Retrieve Store object
*
* @return Mage_Core_Model_Store
*/
public function getStore()
{
if (is_null($this->_store)) {
$this->_store = Mage::app()->getStore();
}
return $this->_store;
}
/**
* Retrieve Request object
*
* @return Mage_Core_Controller_Request_Http
*/
protected function _getRequest()
{
return Mage::app()->getRequest();
}
/**
* Retrieve Response object
*
* @return Mage_Core_Controller_Response_Http
*/
protected function _getResponse()
{
return Mage::app()->getResponse();
}
/**
* Retrieve Domain for cookie
*
* @return string
*/
public function getDomain()
{
$domain = $this->getConfigDomain();
if (empty($domain)) {
$domain = $this->_getRequest()->getHttpHost();
}
return $domain;
}
/**
* Retrieve Config Domain for cookie
*
* @return string
*/
public function getConfigDomain()
{
return (string)Mage::getStoreConfig(self::XML_PATH_COOKIE_DOMAIN, $this->getStore());
}
/**
* Retrieve Path for cookie
*
* @return string
*/
public function getPath()
{
$path = Mage::getStoreConfig(self::XML_PATH_COOKIE_PATH, $this->getStore());
if (empty($path)) {
$path = $this->_getRequest()->getBasePath();
}
return $path;
}
/**
* Retrieve cookie lifetime
*
* @return int
*/
public function getLifetime()
{
if (!is_null($this->_lifetime)) {
$lifetime = $this->_lifetime;
} else {
$lifetime = Mage::getStoreConfig(self::XML_PATH_COOKIE_LIFETIME, $this->getStore());
}
if (!is_numeric($lifetime)) {
$lifetime = 3600;
}
return $lifetime;
}
/**
* Set cookie lifetime
*
* @param int $lifetime
* @return Mage_Core_Model_Cookie
*/
public function setLifetime($lifetime)
{
$this->_lifetime = (int)$lifetime;
return $this;
}
/**
* Retrieve use HTTP only flag
*
* @return bool
*/
public function getHttponly()
{
$httponly = Mage::getStoreConfig(self::XML_PATH_COOKIE_HTTPONLY, $this->getStore());
if (is_null($httponly)) {
return null;
}
return (bool)$httponly;
}
/**
* Is https secure request
* Use secure on adminhtml only
*
* @return bool
*/
public function isSecure()
{
if ($this->getStore()->isAdmin()) {
return $this->_getRequest()->isSecure();
}
return false;
}
/**
* Set cookie
*
* @param string $name The cookie name
* @param string $value The cookie value
* @param int $period Lifetime period
* @param string $path
* @param string $domain
* @param int|bool $secure
* @param bool $httponly
* @return Mage_Core_Model_Cookie
*/
public function set($name, $value, $period = null, $path = null, $domain = null, $secure = null, $httponly = null)
{
/**
* Check headers sent
*/
if (!$this->_getResponse()->canSendHeaders(false)) {
return $this;
}
if ($period === true) {
$period = 3600 * 24 * 365;
} elseif (is_null($period)) {
$period = $this->getLifetime();
}
if ($period == 0) {
$expire = 0;
}
else {
$expire = time() + $period;
}
if (is_null($path)) {
$path = $this->getPath();
}
if (is_null($domain)) {
$domain = $this->getDomain();
}
if (is_null($secure)) {
$secure = $this->isSecure();
}
if (is_null($httponly)) {
$httponly = $this->getHttponly();
}
// setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
setcookie($name, $value, $expire, $path.self::SAMESITE, $domain, $secure, $httponly);
return $this;
}
/**
* Postpone cookie expiration time if cookie value defined
*
* @param string $name The cookie name
* @param int $period Lifetime period
* @param string $path
* @param string $domain
* @param int|bool $secure
* @return Mage_Core_Model_Cookie
*/
public function renew($name, $period = null, $path = null, $domain = null, $secure = null, $httponly = null)
{
if (($period === null) && !$this->getLifetime()) {
return $this;
}
$value = $this->_getRequest()->getCookie($name, false);
if ($value !== false) {
$this->set($name, $value, $period, $path, $domain, $secure, $httponly);
}
return $this;
}
/**
* Retrieve cookie or false if not exists
*
* @param string $neme The cookie name
* @return mixed
*/
public function get($name = null)
{
return $this->_getRequest()->getCookie($name, false);
}
/**
* Delete cookie
*
* @param string $name
* @param string $path
* @param string $domain
* @param int|bool $secure
* @param int|bool $httponly
* @return Mage_Core_Model_Cookie
*/
public function delete($name, $path = null, $domain = null, $secure = null, $httponly = null)
{
/**
* Check headers sent
*/
if (!$this->_getResponse()->canSendHeaders(false)) {
return $this;
}
if (is_null($path)) {
$path = $this->getPath();
}
if (is_null($domain)) {
$domain = $this->getDomain();
}
if (is_null($secure)) {
$secure = $this->isSecure();
}
if (is_null($httponly)) {
$httponly = $this->getHttponly();
}
setcookie($name, null, null, $path, $domain, $secure, $httponly);
return $this;
}
}
@Aveeva Yes, Correct.
You can check with these changes.
samesite=none is added on your website
Also, I have given you an example.you will have to update on others such a page cache and others as below code script changes:
Only update path line code.
Don't update the domain as I have given a refrence.
<script type="text/javascript"> //<![CDATA[ Mage.Cookies.path = '/;samesite=none'; Mage.Cookies.domain = 'domain'; //]]> </script>
@Madhu Rajawat Still getting same error, after successful payment, i see the message "Shopping Cart is Empty"
@Aveeva Try to adding given previous changes too and on Pagecache cookie
and check then again
@Madhu Rajawat You mean this one,
<script type="text/javascript"> //<![CDATA[ Mage.Cookies.path = '/;samesite=none'; Mage.Cookies.domain = 'domain'; //]]> </script>
Where i need to add? same file app/code/core/Mage/Core/Model/Cookie.php or some other file?
@Madhu Rajawat You mean app/code/core/Mage/Core/Model/cache.php page?
@Madhu Rajawat Anything wrong i did?
@Madhu Rajawat Hello Friend, any help thanks.
Hi @Aveeva Cache.php that is not the correct file.
In My case, Issue was occurring due to samesite none was not set on my website. I have applied suggested changes that I have shared with you.
Check if any other places you need to set up samesite none on your website. It is depend om your website. You can check cookie n Application Tab and filter with your website domain.
I can suggest you please check it properly with setting up samesite none on your website as i have shared with you the patch. For more details you will need to find out as per your website.