Skip to content

Fix Auth::user() in Auth.php - Hydration should not regenerate session - #66

Merged
mychidarko merged 2 commits into
leafsphp:v5.xfrom
bennito254:patch-1
Nov 6, 2026
Merged

mychidarko merged 2 commits into
leafsphp:v5.xfrom
bennito254:patch-1

Conversation

@bennito254

Copy link
Copy Markdown
Contributor

Hydration should not regenerate the session

What kind of change does this PR introduce? (pls check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe below

Description

Auth::user() was regenerating the session

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Hydration should not regenerate the session
@mychidarko

mychidarko commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

[BOT]

Thanks for this. Skipping the session_regenerate_id() on every Auth::user() call makes sense.

One side effect to check: passing false also skips the auth.lastActivity and auth.ttl updates, so user() no longer extends the session on each request. Apps that rely on that sliding expiry would see sessions end at the original TTL. I've left this for @mychidarko to decide whether that's the intended behaviour, or whether only the regenerate should be skipped.

CI hasn't run on this PR yet, so it's waiting on a maintainer to approve the workflow.

@mychidarko

Copy link
Copy Markdown
Member

Thanks @bennito254. Passing $session = false stopped the regeneration, but it also skipped refreshing auth.lastActivity and auth.ttl, so active users would get logged out once the TTL ran out from login time.

I pushed a small change to your branch: User now takes a third $regenerate flag, and user() passes true, false. Sessions keep their sliding expiry and only the ID regeneration is skipped. This also fixes the lint failure.

@mychidarko
mychidarko merged commit c3d63a5 into leafsphp:v5.x Nov 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants