Skip to content

Fix StaySignedIn mechanism#2213

Open
Lucas-C wants to merge 1 commit into
shaarli:masterfrom
Lucas-C:fix-staySignedIn
Open

Fix StaySignedIn mechanism#2213
Lucas-C wants to merge 1 commit into
shaarli:masterfrom
Lucas-C:fix-staySignedIn

Conversation

@Lucas-C
Copy link
Copy Markdown

@Lucas-C Lucas-C commented May 24, 2026

Issue symptoms

When performing a login with the longlastingsessionform checkbox set,
the login succeeds but the session only last 1 hour.

Issue analysis

After a successful login, shaarli performs a redirect in LoginController->login().

During this redirect operation, the following state is lost:

  1. SessionManager->staySignedIn is switched from true to false
  2. SessionManager->session['expires_on'] is reset to a short (1 hour) session, due to the call SessionManager->extendSession() made from LoginManager->checkLoginState() in index.php

The consequence is that the SessionManager->session['expires_on'] is never persisted to 1 year value, only to a 1 hour value.

Fix description

First, there is an issue with SessionManager->$staySignedIn that is always initialized to false.

The fix there was to figure if we are in a long-lasting session based on $this->session['expires_on'],
and in this case set it to true in SessionManager->initialize().

The other part of the fix was to ensure that SessionManager->session['expires_on'] is correctly persisted between the call to LoginController->login(), the redirect and the page reload.

My solution was to remove seemingly useless calls to sessionManager->destroy(), sessionManager->start() & sessionManager->regenerateId() in LoginController->renewUserSession().

There may be other solutions to solve this problem, but this seemed the cleanest to me.
Suggestions for alternative fixes are welcome.

Note that there is also this related existing issue to redesign the login management code: #1150

@Lucas-C Lucas-C force-pushed the fix-staySignedIn branch from 91b3ee5 to d3feaaf Compare May 24, 2026 15:48
@Lucas-C Lucas-C force-pushed the fix-staySignedIn branch from d3feaaf to 8a52aca Compare May 24, 2026 15:51
@nodiscc nodiscc self-requested a review May 24, 2026 17:28
@nodiscc nodiscc added the bug it's broken! label May 24, 2026
@nodiscc nodiscc added this to the 0.17.0 milestone May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug it's broken!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants