12

I am submitting a POST request from form and it shows 419 | page expired.

Blade.php:

<form action="<?php echo action('TestsController@store'); ?>" method="post">

Route:

Route::resource('tests', 'TestsController');

Controller:

public function store(Request $request) {
        echo "something something";
}
Omar Saleem
  • 137
  • 1
  • 3
  • 11

4 Answers4

16

Laravel has built-in CSRF protection. Check out the official documentacion.

Add @csrf to you form.

<form action="<?php echo action('TestsController@store'); ?>" method="post">
    @csrf
</form>
Levente Otta
  • 713
  • 6
  • 17
0

As Levente said, first try by putting the @csrf in the form. If that doesn't work, see this thread. It is a duplicate of this issue.

Nikolay
  • 456
  • 3
  • 5
  • You can easily reproduce this error by going to either the login or register page. Don't do anything for, maybe, more than 30 minutes. Then when you click on submit, the `419 Page Expired` shows up. For usability's sake, how do you tell a simple user what just has happened and how to solve it? – Pathros Jun 08 '20 at 16:52
0

In my case, I have solved the problem by setting SSL for my domain. I've tried all the solution, but they didn't work. Then I set the SSL for the domain and it solved the problem.

0

in my case another admin user logged in in my custom Admin panel with OTP

and so he cant login with this new laravel/ui auth login/register default page

saber tabatabaee yazdi
  • 4,404
  • 3
  • 42
  • 58