Repository navigation
Keep a Remember Me session past the inactivity timeout - #2092
Merged
Merged
Conversation
The idle check in User::_isLoggedIn() redirected to node=logout without looking at the remember-me cookie, and logout() clears that cookie. So Remember Me lasted only until the first idle FOG_INACTIVITY_TIMEOUT (default 1 hour). Forum 18315. It went unseen while PHP's 24-minute session GC deleted the session first: ProcessLogin's cookie replay then signed the user back in. #1306 moved sessions to FOG's own 86400s store, so the session now outlives the timeout and the idle branch fires first. The idle branch now skips the logout when the request carries a valid, unexpired remember-me token that belongs to the signed-in user. The check is UserAuth::matches(). The test drives isLoggedIn() on an idle session and fails under seven mutations of the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up on #2092: the named helper had one caller, and a reader of _isLoggedIn() now sees why its two cookie reads differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A user checks Remember Me at sign-in. A few hours later, FOG shows "Session Expired" and asks for a new sign-in. Reported in forum topic 18315 on 1.6.0.14.
Cause
The idle check in
User::_isLoggedIn()redirects tonode=logoutafterFOG_INACTIVITY_TIMEOUThours (default 1). It does not look at the remember-me cookie.logout()then clears thefoguserauth*cookies, so Remember Me ends at the first idle hour.The bug was hidden before #1306/#1307. PHP's 24-minute session GC deleted the session before the 1-hour check fired. The cookie replay in
ProcessLogin::processMainLogin()then signed the user back in with no message. #1306 moved sessions to FOG's own store withgc_maxlifetime86400. The session now outlives the timeout, so the idle branch fires first.Fix
lastactivityrefresh then happens as on any active request.UserAuth::matches()holds the token check. The row must belong to the user, must not be flaggedisExpired, and must not be past its expiry. The selector and the password must both verify against the stored hashes.ProcessLogin::processMainLogin()still has its own copy of the token check. I did not move it ontomatches(): that path reads cookies throughfilter_input(), which the CLI suite cannot supply. An untested rewrite of a working sign-in path is the larger risk. The two copies agree except at the exact expiry second.Test
tests/remember-me-outlives-inactivity.test.phprunsisLoggedIn()on an idle session against the fake DB:lastactivityrefreshes.It also runs
matches()for each refusal case. Seven mutations of the fix each turn the test red on the matching check: the original bug,&&changed to||, swapped cookies, the wrong user id, no user binding, no expiry check, and noisExpiredcheck.Workaround on 1.6.0
Set
FOG_ALWAYS_LOGGED_INto 1, or setFOG_INACTIVITY_TIMEOUTto 24.🤖 Generated with Claude Code