Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skater's avatar

Sometimes I can not connect (419) when I lose session

This is weird... Sometimes the session is lost (this can happen for any reason, or even session timeout ...), this is OK. So I'm redirect to LOGIN page.

But when I login I get a 419 error... a "CSRF token mismatch."

I go again to the login page, reload page , and I see the CSRF hidden field in the form, with a key ... But it does not work.

For some time, the login is "stuck" and I can not login again ...

never ... until I clean all the session data (cookie) from the Chrome browser.

Then, from scratch (obviously) login works again.

Any reason for this "login stuck" issues ?

0 likes
4 replies
lbecket's avatar

Are you using any of the Laravel starter kits for authentication or have you implemented your own?

lbecket's avatar

So, I wasn't expecting this at all, but I may have accidentally replicated the behavior... at least to a degree. I went to the login of my own application that's using Breeze and I deleted the cookie. After doing that, attempting to login gave me a 419 that didn't seem to go away until I did a hard refresh. Not really sure what to make of that honestly. Is there a chance that you've done something to change the expiration time of your cookies?

Are you able to replicate the behavior in another browser? Would be good to know if this is an application issue or a browser issue.

skater's avatar

@lbecket I don't clean any cookies ... In fact, the cookie is in the browser, with the session ID, and that session is in the database.

What I told you is that, for resolving the situation, I have to delete either the browser cookie or the session id in database, that's to say, to remove completely the session.

I will investigate a way to duplicate !

Please or to participate in this conversation.