Laravel 5.5 login and register page says:The page has expired due to inactivity.[TokenMismatchException]

不羁岁月 提交于 2019-11-28 09:24:54

I had the same problem on localhost:8000 (php artisan serve). Maybe it's coincidence, but try on "clean browser" , other than you used with previous development. For me it worked.

It seems that the problem is with cookies from development with previous Laravel versions, on the same url.

i think you missed csrf token.

dont forget to use {!! csrf_field() !!}

In my case, I've got the same error message and then figured that I missed to add csrf_token

{{ csrf_field() }}

Or without form helper that will be,

<input type="hidden" name="_token" value="{{ csrf_token() }}">

If that doesn't work, then-

Refresh the browser cache and hopefully it will work, thanks.

I had the same issue and it was because I was using virtualhost and I setup below variable to mydomain.com. in config/session.php file

'domain' => env('SESSION_DOMAIN', 'mydomain.com'),

When I changed it to null then it started working

'domain' => env('SESSION_DOMAIN', 'null'),

I don't know what is the reason behind it but it is working fine now.

mark edosa

I had this same issue. vagrant reload --provision worked for me

Add csrf token

       <input type="hidden" name="_token" value="{{ csrf_token() }}">

It appears to be permission settings on either storage and/or bootstrap/cache.

I'm using a Cloudways server. I reset permissions on my server under Application Settings and it now works. On my local development server the equivalent was to set chmod 777 on storage.. I had used 755 previously and the error persisted.

Hni Klsi

Make sure your User.php model exist in app folder and fields must be define in this model.

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
}

if you created a new project localhost You need view config/session line : 166 if 'secure' => true , you need edit 'secure' => false, When you up the host or server, re-config => true sorry i know a little english , hope can help you

I would also keep csrf_token in a meta tag.

<meta name="csrf-token" content="{{ csrf_token() }}">

I was only testing post requests for my api and came across the same issue. I resolved it by adding my route to the Middleware VerifyCsrfToken's $except array i.e. go to app/Http/Middleware/VerifyCsrfToken and add

protected $except = [
        'your/route'
];

But if your requests are from some front-end platform or views, it's advisable to add {{ csrf_field() }} in the form that sends the request.

Hi for the group paths that you want to apply to everyone, use this method, which is my 5.5 larval version. Use the star => go to app/Http/Middleware/VerifyCsrfToken and add

protected $except = [
    '/user/*'
];

This is also my user's path

Route::group(['prefix' => 'user', 'namespace' => 'User', 'as' => 'user.'] , function (){

This issue is mainly caused because you don't have the csrf token in your form. During csrf token verification it fails, that's why you are getting this page. Laravel generally needs csrf token in all its forms. You can add a csrf token simply by adding this inside the form.

 {{ csrf_field() }}

Another method of doing this is you can exclude your route in the verifycsrftoken middleware.

Just add a protected field in the middleware with your route name.

protected $except=[
                    '1st route',
                    '2nd route',
                    .
                    .
                  ];

This should work.

Had this issue as well! Solved it by:

  1. Clearing browser session storage and cookies.
  2. Running php artisan cache:clear
  3. Ensuring the storage/framework/sessions folder was empty, except for the .gitignore.
  4. Restarting dev environment.
user8572385

try this out look for the forms in the views of the login and register pages and add the following line in the forms

<input name="_token" type="hidden" value="TtQX3LwLMvrhLcOr75dDP2WzvHve0TE7eyilRebW">
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!