Skip to content

Commit

Permalink
Merge pull request #6 from sozgat/master
Browse files Browse the repository at this point in the history
Chrome Samesite cookie control added.
  • Loading branch information
sozgat authored Feb 11, 2021
2 parents 6ba589a + cdb65ee commit c325890
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions iyzipay/iyzipay.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __construct()
$this->commissionAmount = $this->l('commissionAmount');



$this->confirmUninstall = $this->l('are you sure ?');

$this->limited_countries = array('TR','FR','EN');
Expand All @@ -82,6 +82,8 @@ public function __construct()
$this->extra_mail_vars = array(
'{instalmentFee}' => '',
);

$this->checkAndSetCookieSameSite();
}

/**
Expand Down Expand Up @@ -344,7 +346,7 @@ private function setIyziTitle()
*/
public function hookBackOfficeHeader()
{

if (Tools::getValue('configure') == $this->name) {
$this->context->controller->addJS($this->_path.'views/js/back.js');
$this->context->controller->addCSS($this->_path.'views/css/back.css');
Expand Down Expand Up @@ -473,6 +475,39 @@ public function hookPaymentReturn($params)
return $this->display(__FILE__, 'views/templates/front/confirmation.tpl');
}

private function setcookieSameSite($name, $value, $expire, $path, $domain, $secure, $httponly) {

if (PHP_VERSION_ID < 70300) {

setcookie($name, $value, $expire, "$path; samesite=None", $domain, $secure, $httponly);
}
else {
setcookie($name, $value, [
'expires' => $expire,
'path' => $path,
'domain' => $domain,
'samesite' => 'None',
'secure' => $secure,
'httponly' => $httponly
]);


}
}

private function checkAndSetCookieSameSite(){

$checkCookieNames = array('PHPSESSID','OCSESSID','default','PrestaShop-','wp_woocommerce_session_');

foreach ($_COOKIE as $cookieName => $value) {
foreach ($checkCookieNames as $checkCookieName){
if (stripos($cookieName,$checkCookieName) === 0) {
$this->setcookieSameSite($cookieName,$_COOKIE[$cookieName], time() + 86400, "/", $_SERVER['SERVER_NAME'],true, true);
}
}
}
}

/**
* @return mixed
*/
Expand Down

0 comments on commit c325890

Please sign in to comment.