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

vincent15000's avatar

Error 419 Page expired on the login page

Hello,

I try to login to a Laravel application, I see error 419 Page expired for the login page.

I think that it occurs when I don't have logged out and after the session lifetime (some days after) I try to log in.

I remember having already a similar problem when the session cookie was still stored in the browser, but not valid after the session lifetime.

How to prevent to have this error ? Sure I can manually delete the cookie in the browser, but the users won't do that.

Thanks for your help.

V

0 likes
10 replies
tykus's avatar

I would suppose your login page is sitting idle for an extended period. You could get that page to refresh automatically every N seconds (within the Session lifetime) , e.g.

<meta http-equiv="refresh" content="6000">
1 like
tykus's avatar

@vincent15000 no, it will be the same Session if the lifetime has not already expired; otherwise it will be a new Session. This solution is intended to add the meta tag only on the login page.

Why, are you worried about keeping an authenticated user session alive? I would expect the Illuminate\Auth\Middleware\RedirectIfAuthenticated to prevent authenticated users being able to visit the login page in the first case.

1 like
vincent15000's avatar

@tykus I worry about this because it happened today with an application that I'm developing (it will be in production in March). I think that I have logged in, then I let the page inactive for 3 hours and I got this error.

tykus's avatar

@vincent15000 help me to understand the issue; if you have signed in already, why are you on the login page at all?

1 like
vincent15000's avatar

@tykus Because the session has expired and I think that the cookie isn't reset in the browser.

vincent15000's avatar

@Snapey Thank you for your answer ... well ... your article is very interesting.

Is your solution a valid solution even if, for example, I log in, then I don't log out, but I just turn off my computer and in some 6 hours I turn it on and I try to log in ?

Snapey's avatar

@vincent15000 when you turn on your computer you have no session, until you load the web page, then you have a session and a valid csrf token, so with or without the suggested code, this is not an issue, and is the same as you accessing the site for the very first time

1 like

Please or to participate in this conversation.