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.

samesite cookie settings lost

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\SessionManager or 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

Comments

mxr576 created an issue. See original summary.

mxr576’s picture

mxr576’s picture

Issue summary: View changes
StatusFileSize
new143.88 KB
andypost’s picture

Would be great to link it to related symfony 6 issue, yo prevent further regressions

mxr576’s picture

vagelis-prokopiou’s picture

Issue summary: View changes
mxr576’s picture

Let's cross-reference another because some work is already done there.

mxr576’s picture

and let's also add this to the common meta parent issue...

znerol’s picture

@mxr576: could you please check whether #2238561 fixed this issue and close this one if appropriate?

andypost’s picture

Looks only Todo is left for the issue to fix

andypost’s picture

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

znerol’s picture

Status: Active » Closed (outdated)

Closing this as outdated.