Skip to content

Conversation

@valorin
Copy link
Contributor

@valorin valorin commented Sep 29, 2025

Use Session::regenerate() instead of Session::migrate() during the login flow.

@taylorotwell
Copy link
Member

@valorin does this have any risk of breaking changes with the other changes we've made in terms of regenerating and migrating twice, etc.

@valorin
Copy link
Contributor Author

valorin commented Sep 30, 2025

@taylorotwell Nope, there should be no negative effects or breaking changes associated with this and the other changes we made. 👍

The login flow already called migrate() and regenerate() together, with the only difference between migrate() and regenerate() being generating a random string and storing it in the session:

public function regenerateToken()
{
$this->put('_token', Str::random(40));
}

@taylorotwell taylorotwell merged commit 975d60a into laravel:12.x Oct 8, 2025
63 checks passed
@AhmedAlaa4611
Copy link
Contributor

Should we also invalidate() and regenerateToken() in logout()?

@ConorEdwardsCP
Copy link

This broke our workflow. Regenerating this token causes Livewire to blow up because it doesn't get the updated token. It keeps trying to use the existing session token, and gives a 419 error every time it tries to update anything.

We're currently using laravel/framework 12.33.0, and bumping to 12.34.0 causes our sign up flow to blow up.

Is there a way to work around this?

@valorin
Copy link
Contributor Author

valorin commented Nov 19, 2025

This feels like an issue that should be fixed in Livewire, as rotating the CSRF token is critical for security across authentication boundaries.

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.

4 participants