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

asdfowkw's avatar

TokenMismatchException

Hello!

I'm having a problem with this TokenMismatchException.

Everything works fine BUT if I go to the website without logging in, and then leave it open for X hours and then click login I get TokenMismatchException, how do I make it so It dosnt expire?

0 likes
3 replies
jimmck's avatar

Hi, Tokens expire, so you have to get a new one. You can put one in your header or have the login form get a new one and return it to login page.

<!doctype html>
<html>
<head>
    <title>Manage Contact Types</title>
    <link rel="stylesheet" href="/assets/css/main.css">
    <link rel="stylesheet" href="/assets/css/alertify.css" />
    <link rel="stylesheet" href="/assets/css/themes/default.css" />
    <meta name="csrf-token" content="<?php echo csrf_token() ?>"/>
</head>
<body>
...
asdfowkw's avatar

Ye the problem is that if the page is open for XX hours and then someone press login they will just get an error page, i dont want that to happen.

asdfowkw's avatar

I mean if they press login without refreshing the page

Please or to participate in this conversation.