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

behnamazimi's avatar

Is "The page has expired due to inactivity" issue a bug in Laravel 5.5?

This issue really confused me! I asked it many times in many places! I searched for a solution in stack and I did what I had to do, but the issue not solved.

At first I thought that problem related to services and providers, and I asked this question but I create a new project with Laravel 5.5.0 and without adding any complexity I just added a post route and call it in form action and nothing changed!

Please help, I really confused and I did so much of a project with Laravel 5.5 in the hope that perhaps the issue will be resolve!

Edit:

As I explained above, I did all basics such as adding {{csrf_field()}} to form or clearing cache, view, routes and config by artisan commands! but my problem is still here!

To being sure about problem, I created a new project by this command laravel new testProject, and I just add a form to the welcome blade that includes csrf token too. and I added a post route that return $request->all();, but my problem still is there!

0 likes
20 replies
JoaoPedroAS51's avatar

Please, can you show me your code? Form, route and controller?

behnamazimi's avatar

@JoaoPedroAS51 Here is my test method in Controller:

 public function test(Request $request){
        return $request->all();
    }

my web.php:

Route::get('/', function () {
    return view('welcome');
});

Route::post('/',"TestController@test")->name('test');

and here is my form that is in welcome.blade.php:

<form action="{{route('test')}}" method="POST">
    {{csrf_field()}}
    <input type="text" name="name">
    <button type="submit">send</button>
</form>
JoaoPedroAS51's avatar

Try to change this:

public function test(Request $request)
{
    return $request->all();
}

to this:

public function test(Request $request)
{
    return $request::all();
}

or this:

public function test()
{
    return request()->all();
}
martinbean's avatar

@JoaoPedroAS51 Why? The second one will only work if the all() method is static (it’s not), and the third is just an alias for $request->all().

wilburpowery's avatar

This is indeed a CSRF problem. I received this message once and it was because I was not sending the csrf token with my request. Very strange your still getting it, since you are indeed sending the token.

behnamazimi's avatar

@wilburpowery I have two guard in my main project and in some cases token mismatch exception occurs. I checked framework/session directory and in every reload a new session file create there!

wilburpowery's avatar

Whenever you get that error, if you refresh the page, are you still authenticated?

When I was on Windows last year I had a problem where my session would log out every now and then when I changed my PHP code. It's very weird. @behnamazimi

behnamazimi's avatar

When I logged in every thing is OK, but when I reload the page the authentication lost! I really confused. I really don't know what should I do! I did huge percent f a project with this version on laravel(5.5) but this issue ruined everything! ☹️ @wilburpowery

wilburpowery's avatar
Level 23

This is just an issue for Windows users on Local Environment. I suffered a lot with this also when on Windows. Once you deploy to your production server, you won't have any issue at all.

It's important to note that this is not an issue with Laravel 5.5 version only. I first saw this issue in version 5.2.

2 likes
wilburpowery's avatar

I think a good fix for this would maybe be using something like Homestead. Honestly I only suffered this problem when using Windows. Have you evered used Homestead?

ejdelmonico's avatar

In stead of using Homestead, consider using Vessel by @fideloper. It is very simple to use. All you need is to install the Docker app and then follow the Vessel docs. Works great, lasts a long time.

2 likes
behnamazimi's avatar

@wilburpowery No I don't. I checked your reply as a solution, I test my project on linux os and it's completely true! thanks a lot for your replies. could you answer my stack question too? this Q

1 like
Clayts's avatar

I also experience this Problem. I uploaded my laravel project in AWS under ubuntu 16.04 server running in nginx.

I also test the fresh install laravel and add make:auth but i still get

"The page has expired due to inactivity.

Please refresh and try again. "

any idea how to solve it?

ymssrikanth's avatar

Experiencing the same problem. Its working fine in the local environment but it is not working in the cloud server (Godaddy Shared Linux Hosting). Done everything I got and really want to know the solution ASAP.

breakboyandre's avatar

For those who still has problem and nothing helped. Pay attention on php.ini mbstring.func_overload parameter. It has to be set to 0. And mbstring.internal_encoding set to UTF-8. In my case that was a problem.

breakboyandre's avatar

For those who still has problem and nothing helped. Pay attention on php.ini mbstring.func_overload parameter. It has to be set to 0. And mbstring.internal_encoding set to UTF-8. In my case that was a problem.

Please or to participate in this conversation.