The session is not being updated.

Created on 17 August 2024, 3 months ago
Updated 17 September 2024, about 2 months ago

Problem/Motivation

The issue that is happening is that, after updating to Drupal 10.3.0, it was noticed that the session is not being updated. So, if I set the session to 30 minutes, after the user is inactive on the site for that time, they are logged out. In Drupal 10.2.7, every time there was a request, this time was recalculated and updated.

Steps to reproduce

Create the services.yml file and change gc_maxlifetime to 120. Also, change cookie_lifetime to 120. You will be able to use the site normally, but you will be logged out after 2 minutes.

parameters:
  session.storage.options:
    cookie_samesite: Lax
    gc_maxlifetime: 120
    cookie_lifetime: 120

Proposed resolution

I think the issue is happening because it's not saving the new session.
Moreover, even forcing it to enter the if, it doesn't work.

https://git.drupalcode.org/project/drupal/-/blob/10.3.0/core/lib/Drupal/...

🐛 Bug report
Status

Needs work

Version

10.3

Component
BigPipe 

Last updated 1 day ago

Created by

🇧🇷Brazil charlliequadros

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @charlliequadros
  • 🇧🇷Brazil charlliequadros

    I created an MR. I'm not sure if it's the best solution, but it solves the problem until someone can fix it properly. I'm available to work on this ticket if anyone can help me figure out a permanent solution to the issue.

  • Pipeline finished with Failed
    3 months ago
    Total: 707s
    #256382
  • Pipeline finished with Failed
    3 months ago
    Total: 741s
    #256381
  • My expectation is the opposite—the session should end.

  • 🇧🇷Brazil rafael maito

    Thank you, charlliequadros. This solution worked for me, adding this change the session is being updated in each request.
    Hi cilefen, Is your session never ending?

  • The session should end after gc_maxlifetime. No?

  • 🇧🇷Brazil charlliequadros

    Hi @cilefen

    In Drupal version 10.2.7, the user's session was updated with each request, meaning that as long as the user interacted with the site, the session time was refreshed, preventing it from expiring during use. However, after updating to version 10.3.0, this behavior changed: the session time is no longer updated. So, if the timeout is reached, the session will be automatically closed, regardless of what the user is doing, such as during content creation or editing, for example. What's not working after the update is the session time being refreshed while the user is interacting with the site.

  • As I mentioned my expectation is the opposite of yours.

    Anyway, perform a git bisect on a Git working copy of Drupal core to understand which commit changed this.

  • 🇧🇷Brazil charlliequadros

    Hi @cilefen,

    I followed your suggestion to identify when the issue was introduced.

    This issue arose during the resolution of this issue. https://www.drupal.org/project/drupal/issues/3414287 📌 Avoid reading session from the database multiple times during a request Needs work

    I couldn’t determine which call was removed to avoid two database requests. Was it "$request->getSession()->save();" or "$this->session->start();

  • 🇧🇷Brazil rafael maito

    Hello charlliequadros and cilefin,

    After some investigation, here is my conclusion.

    This change is related to the big pipe, here ( https://www.drupal.org/project/drupal/issues/3414287 📌 Avoid reading session from the database multiple times during a request Needs work ) is the Drupal issue. So checking this, the changes between Drupal versions 10.2.7 and 10.3.0 in BigPipe were changes to implement enhance performance and security in the delivery of dynamic content on web pages. However, might be affecting how the session is managed, particularly concerning the SSESS cookie's update timing.

    In Drupal 10.2.7, BigPipe handled session management by reopening the session during the rendering of placeholders and then closing it afterward. This ensured that the session's expiration time was updated as content was progressively delivered to the user. However, in Drupal 10.3.0, the changes of these pre- and post-rendering tasks may be disrupting the regular update process of the SSESS cookie.

    These changes could be preventing the session from being reopened or correctly managed during placeholder rendering, leading to issues with the SSESS cookie's expiration time.

    If I revert the changes made here (https://git.drupalcode.org/project/drupal/-/merge_requests/6441/diffs#6c...) in the files BigPipe.php and BigPipeResponse.php, it works as before.

  • 🇧🇷Brazil isa.bel Balneário Camboriú
Production build 0.71.5 2024