Fix in last release leads to premature user logout

Created on 15 February 2022, almost 3 years ago
Updated 15 October 2024, about 2 months ago

Based on my testing it looks like fix made in https://www.drupal.org/project/session_based_temp_store/issues/3257214 β†’ leads to premature user logout. Perhaps there's an issue with the session-clearing mechanism in that change?

Downgrading back to version 1.1 seems to have fixed the problem.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡ΏCzech Republic milos.kroulik

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΈπŸ‡°Slovakia poker10

    This seems to be still an issue. I think the steps to reproduce can be the following:

    1. install the module
    2. try to use the SessionBasedTempStore::get() method for example in event subscriber subscribing to KernelEvents::REQUEST

    Calling the get() method:

          $temp_store_factory = \Drupal::service('session_based_temp_store');
          $temp_store = $temp_store_factory->get('xxx');
    

    in that event subscriber will call SessionBasedTempStore::getOwner(), which will then try to evaluate this condition:

          if (!$session->has('core.tempstore.private.owner')) {
            // Remember that we did not have started a session before.
            $session_already_started = FALSE;
            // This generates a unique identifier for the user.
            $session->set('core.tempstore.private.owner', Crypt::randomBytesBase64());
          }
    

    The issue is, that this condition can pass even for authenticated users, causing $session_already_started = FALSE; to be set for logged-in users. Then, there is another code, which is run later:

          // Clear session if there was no session before.
          if (!$session_already_started) {
            $session->clear();
          }
    

    Which will logout the logged-in user.

    Maybe we need to generate $session_store_id for logged-in users differently, or fix the problematic condition in SessionBasedTempStore::getOwner()?

    Thanks!

  • πŸ‡·πŸ‡ΊRussia nortmas Crimea/Thailand

    Thanks! Unfortunately, I'm not working with Drupal anymore. I'm not sure if I have time to maintain this module in the future.
    Anyway, I'll try to take a look when I have time.

Production build 0.71.5 2024