Fix default session cookie name for non-alphanumeric APP_NAME#59588
Draft
vashukarn wants to merge 1 commit intolaravel:13.xfrom
Draft
Fix default session cookie name for non-alphanumeric APP_NAME#59588vashukarn wants to merge 1 commit intolaravel:13.xfrom
vashukarn wants to merge 1 commit intolaravel:13.xfrom
Conversation
Since the switch to Str::snake() for the default session cookie name, APP_NAME values containing characters like brackets or dots produced cookie names with characters that browsers refuse to round-trip, breaking session persistence and silently logging users out. Wrap the result in Str::slug(..., '_') so the resolved cookie name is always RFC 6265 safe while preserving the snake_case style for normal APP_NAME values.
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
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
Fixes #59344. Since #56172 switched the default session cookie name from
Str::slug(APP_NAME, '_')toStr::snake(APP_NAME), applications whoseAPP_NAMEcontains characters like[,],., or whitespace produce cookie names browsers refuse to round-trip. The result: every request creates a new session and authenticated users are silently logged out.Examples from the issue:
APP_NAME="[LOCAL] My Awesome App"→[_l_o_c_a_l]_my_awesome_app_sessionAPP_NAME="admin.domain"→admin.domain_sessionThis wraps the snake-cased result in
Str::slug(..., '_')so the resolved name is always restricted to RFC 6265–safe characters ([A-Za-z0-9_]) while preserving the snake_case style for normalAPP_NAMEvalues introduced in #56172.My App→my_app_session(unchanged)[LOCAL] My Awesome App→l_o_c_a_l_my_awesome_app_sessionadmin.domain→admindomain_sessionTest plan
tests/Integration/Session/SessionCookieNameTest.phpcovering simple names, bracketed names, dotted names, and a regex check that the resolved name is always RFC 6265 safe across a variety of unsafe inputs.