Repository navigation
Conversation
SessionManager::checkAndLoadFromCookie() constructed the resumed Session with 'name' => 'x' instead of the requested session name. Because the name becomes the cookie name, the resumed session's cookie (and any Set-Cookie header, including a regenerated ID on login) was emitted as 'x=<id>' rather than '<realName>=<id>', so the browser never adopted the correct/updated session cookie. Use $sName when constructing the resumed session. Adds a regression test asserting the resumed session keeps its requested name and that the emitted cookie header uses that name.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #426 +/- ##
============================================
+ Coverage 81.94% 81.96% +0.02%
Complexity 3293 3293
============================================
Files 106 106
Lines 9735 9735
============================================
+ Hits 7977 7979 +2
+ Misses 1758 1756 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
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.



Summary
Resume sessions under their real name in
SessionManager::checkAndLoadFromCookie()instead of a hard-coded'x', so session cookies are emitted under the correct name.Motivation
checkAndLoadFromCookie()looks up the session ID by the requested name but then constructs the resumedSessionwith'name' => 'x'. Since the name becomes the cookie name (setNameHelper()→Cookie::setName()), the resumed session'sgetName()returns'x'and every emittedSet-Cookieheader is written asx=<id>instead of<realName>=<id>. The browser's real session cookie is never updated. Combined withreGenerateID()on login (session-fixation flow), the regenerated ID is emitted under the wrong name, so the browser keeps sending the old (pre-regeneration) ID and the user appears logged out / the new ID is never adopted. Fixes #425.Changes
SessionManager::checkAndLoadFromCookie()now constructs the resumed session with'name' => $sName(the requested name) instead of'x'.UI Changes
Not applicable.
How to Test / Verify
New regression test in
tests/WebFiori/Framework/Tests/Session/SessionsManagerTest.php:testResumedSessionKeepsRequestedName— persists a session under a real name, resets the manager (new request), resumes it by ID, and asserts the resumed session isRESUMED, keeps its requested name (not'x'), and thatgetCookiesHeaders()emitsSet-Cookie: <realName>=....The test fails on the pre-fix code (
Expected 'wf-session' / Actual 'x') and passes after. FullSessionsManagerTestclass: 28 tests / 97 assertions passing (6 pre-existing DB skips).Breaking Changes and Migration Steps
None. This corrects the cookie name of resumed sessions; no application-facing API changes.
Checklist
Related issues
Closes #425