bug #29676 [HttpFoundation] Fix erasing cookies issue (eiannone)

This PR was submitted for the master branch but it was merged into the 4.2 branch instead (closes #29676).

Discussion
----------

[HttpFoundation] Fix erasing cookies issue

| Q             | A
| ------------- | ---
| Branch?       | 4.2 (to be switched when merging)
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29675
| License       | MIT

Prevent replacing existing cookies when starting or regenerating session on PHP < 7.3 with 'cookie_samesite' option.
See issue #29675

Commits
-------

b40801a492 Fix erasing cookies issue
This commit is contained in:
Fabien Potencier 2019-01-01 19:29:28 +01:00
commit 42ac8afde0

View File

@ -153,7 +153,7 @@ class NativeSessionStorage implements SessionStorageInterface
if (null !== $this->emulateSameSite) {
$originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
if (null !== $originalCookie) {
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite));
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite), false);
}
}
@ -225,7 +225,7 @@ class NativeSessionStorage implements SessionStorageInterface
if (null !== $this->emulateSameSite) {
$originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
if (null !== $originalCookie) {
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite));
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite), false);
}
}