Problem/Motivation
Symfony's built-in session management implements a workaround for handling changed signature of some cookie/session management related functions in PHP 7.3, like setcookie(), session_get_cookie_params(), etc. This is implemented in the NativeSessionStorage since this commit.
\Drupal\Core\Session\SessionManager extends this class but in some oerriden methods, like start(), destroy(), it does not call the parent method. Due to this, important tweaks in upstream, like proper handling of SameSite cookie policy, are not available in Drupal.
It also calls setcookie() in a few places directly without handling different signatures of the method and passing site-wide configurations (like SameSite cookie policy settings) stored in SessionConfiguration.

This is the workaround in upstream for setcookie(): https://github.com/symfony/http-foundation/blob/v3.4.41/Session/Storage/...
Note: There is a todo in the class, probably it is time to address it. :)
* @todo
* In fact the NativeSessionStorage class already implements all of the
* functionality required by a typical Symfony application. Normally it is not
* necessary to subclass it at all. In order to reach the point where Drupal
* can use the Symfony session management unmodified, the code implemented
* here needs to be extracted either into a dedicated session handler proxy
* (e.g. sid-hashing) or relocated to the authentication subsystem.
Steps to reproduce
Proposed resolution
Remaining tasks
- TBD what would be the best way to address this issue, should we keep patching our own
\Drupal\Core\Session\SessionManageror rather find a better way, a way that allows leveraging the most from upstream can provide.
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | samesite_cookie_settings_lost.png | 143.88 KB | mxr576 |
Comments
Comment #2
mxr576Comment #3
mxr576Comment #4
andypostWould be great to link it to related symfony 6 issue, yo prevent further regressions
Comment #5
mxr576Are you referring to this one?
Comment #6
vagelis-prokopiou commentedComment #7
mxr576Let's cross-reference another because some work is already done there.
Comment #8
mxr576and let's also add this to the common meta parent issue...
Comment #9
znerol commented@mxr576: could you please check whether #2238561 fixed this issue and close this one if appropriate?
Comment #10
andypostLooks only Todo is left for the issue to fix
Comment #11
andypostComment #17
znerol commentedClosing this as outdated.