View:
<form action="/checklogin" method="post" enctype="multipart/form-data" class="account-form" id="login_form_order_page">
{{ csrf_field() }}
<div class="error-wrap"></div>
<div class="form-group">
<input type="text" name="email" class="form-control" placeholder="Email*" required>
</div>
<div class="form-group">
<input type="password" name="password" class="form-control" placeholder="Password*" required>
</div>
<div class="form-group btn-wrapper">
<button type="submit" id="login_btn" class="submit-btn">Login</button>
</div>
<div class="row mb-4 rmber-area">
<div class="col-6">
<div class="custom-control custom-checkbox mr-sm-2">
<input type="checkbox" name="remember" class="custom-control-input" id="remember">
<label class="custom-control-label" for="remember">Remember Me</label>
</div>
</div>
<div class="col-6 text-right">
<a class="d-block" href="/register">Create New account?</a>
<a href="login/forget-password">Forgot Password?</a>
</div>
</div>
<div class="col-lg-12">
<div class="social-login-wrap">
</div>
</div>
</form>
Route web.php:
Route::POST('/checklogin', 'HomeController@checklogin');
I am submitting the form with csrf still after submitting form 419|Page Expired Error.
After adding session_start() method on page it shows headers already sent.
3
Answers
hello This error is due to csrf token not being sent or I think this warning is due to session
step 1 : add csrf like
@csrf
step 2 : create session like
session('key', 'default');
If it doesn’t work add meta tag
<meta name="csrf-token" content="{{ csrf_token() }}">
If it still doesn’t work
php artisan cache:clear
I hope your bugs will be solved soon
This can happen sometimes when you have a webpage left open on your browser without any activity for 2+ hours. Your session ends up expiring and the CSRF token becomes invalid/expired.
As the other commenter suggested, you can use the blade directive
@csrf
to replace the other code here:{{ csrf_field() }}
Otherwise you can try clearing cache
php artisan cache:clear
or also try runningcomposer dump-autoload
Go to your browser settings -> privacy and security -> cookies and other site data -> see all data and permissions: clear all data (or a specific site like google.com) then run: php artisan config:cache or php artisan optimize:clear
that worked for me