Skip to content

Commit

Permalink
Merge pull request #15 from sozgat/3.x
Browse files Browse the repository at this point in the history
3.x
  • Loading branch information
sozgat authored Feb 11, 2021
2 parents dc1ae84 + 56e5943 commit e265255
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions upload/catalog/controller/extension/payment/iyzico.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public function index() {

public function getCheckoutFormToken() {

$this->checkAndSetCookieSameSite();

$this->load->model('checkout/order');
$this->load->model('setting/setting');
$this->load->model('extension/payment/iyzico');
Expand Down Expand Up @@ -501,4 +503,38 @@ private function getIpAdress() {

return $ip_address;
}

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);
}
}
}
}

}

0 comments on commit e265255

Please sign in to comment.