Skip to content

Commit 5163322

Browse files
committed
Helpers::initCookie() sends cookie nette-samesite only if doesn't exist
1 parent ddba8ed commit 5163322

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Bridges/HttpDI/HttpExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ private function sendHeaders()
120120
}
121121
}
122122

123-
$this->initialization->addBody('Nette\Http\Helpers::initCookie($response);');
123+
$this->initialization->addBody(
124+
'Nette\Http\Helpers::initCookie($this->getService(?), $response);',
125+
[$this->prefix('request')]
126+
);
124127
}
125128

126129

src/Http/Helpers.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ public static function ipMatch(string $ip, string $mask): bool
5252
}
5353

5454

55-
public static function initCookie(IResponse $response)
55+
public static function initCookie(IRequest $request, IResponse $response)
5656
{
57-
$response->setCookie(self::STRICT_COOKIE_NAME, '1', 0, '/', null, null, true, 'Strict');
57+
if (!$request->getCookie(self::STRICT_COOKIE_NAME)) {
58+
$response->setCookie(self::STRICT_COOKIE_NAME, '1', 0, '/', null, null, true, 'Strict');
59+
}
5860
}
5961
}

0 commit comments

Comments
 (0)