Skip to content

Commit

Permalink
+composer json and samesite issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sozgat committed Jul 19, 2021
1 parent b826d43 commit 51b5d61
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions Controller/Request/PayWithIyzico.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function execute()
$productMetadata = $objectManager->get('Magento\Framework\App\ProductMetadataInterface');
$magentoVersion = $productMetadata->getVersion();

$this->checkAndSetCookieSameSite();

$rand = uniqid();

Expand Down Expand Up @@ -138,4 +139,37 @@ public function execute()

}

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

}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "iyzico/module-paywithiyzico",
"name": "iyzico/paywithiyzico",
"description": "pay with iyzico Payment Gateway For Magento 2",
"type": "magento2-module",
"version": "1.0.0",
Expand Down

0 comments on commit 51b5d61

Please sign in to comment.