Pages

31 July, 2021

419 Page Expired Laravel 7.0, 8.0 - After Login

419 Page Expired Laravel login
419 Page Expired Laravel 7.0, 8.0 - After Login

 

 

 When Change one Server To Another Server Then Login Expire Error Show  => 419


Laravel Project Run On Localhost But Live Server Login Error Show 419 or Page Expired 

Then You Follow These Step : 100% your problem solve .


Solution -1

Just add @csrf following right after your form opening tag line. It should look like this:

 

<form class="singn-form" method="POST" action="{{ route('register') }}">
@csrf
....
</form>
 
Use this in the head section instead of @csrf :
<meta name="csrf-token" content="{{ csrf_token() }}">
 
php artisan cache:clear 
 

chmod -R 755 storage

chmod -R 755 vendor

chmod -R 644 bootstrap/caches

 

domain' => env('SESSION_DOMAIN', null),
'secure' => env('SESSION_SECURE_COOKIE', false), // in case of cookie
 

These step by step approach fixes the error and make Laravel working again

chmod -R 644 bootstrap/caches this will cause the following error ` tempnam(): file created in the system's temporary directory ` in laravel 8. Give 755 permission to bootstrap/cache

chmod -R 777 bootstrap/cache not chmod -R 644 bootstrap/caches

 

----------------------------

Yes, the problem is caused by the csrf_token. @csrf return only the token but which is going to be sent so use csrf_field() which will generate a hidden input field. Or you can remove this route from middleware like below, which is not recommended as it's your authenticate route. Also, try

Clear cache : php artisan cache:clearGenerate new app key : php artisan key:generate

 

class VerifyCsrfToken extends Middleware
{
/**
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
*
* @var bool
*/

protected $addHttpCookie = true;

/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/

protected $except = [
'/login'
];
}

 

  or you can use this type ;

 

As others said this should be a csrf_token issue. However, in my case, I couldn't find a proper solution yet so, I temporarily removed all routes from middleware for testing the rest of the functions.

PS:- Do not do this in production.

class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/

protected $except = [

'*',

];
}

 

 

  

 

No comments:

Post a Comment

Thanks