skip to Main Content

the thing is that the project is working before.. then all of sudden i started seeing 419 on all my post request and i have @csrf on all my forms too

                        <form method="POST" action="{{ route('login') }}">
                            @csrf
                            <div class="form_title pb-2">
                                <h4>@lang('Login Here')</h4>
                            </div>
                            <div class="mb-4">
                                <input class="form-control" type="text" name="username" value="{{old('username')}}" placeholder="@lang('Email Or Username')">
                                @error('username')<p class="text-danger mt-1">@lang($message)</p>@enderror
                                @error('email')<p class="text-danger mt-1">@lang($message)</p>@enderror
                            </div>

2

Answers


  1. Allow your url in VerifyCsrfToken which is inside middleware.For example, if your url is /login then write in VerifyCsrfToken file something like below:
    protected $except = [
            'login'
        ];
    
    Login or Signup to reply.
  2. Yes, the first case is you have to add @csrf field, which you have already done.

    First try running php artisan cache:clear

    Try this if you are on localhost

    SESSION_DOMAIN=
    

    In config/session.php

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

    Or if you’re on server

     SESSION_DOMAIN=mydomain.com 
    

    In config/session.php

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

    And don’t forget running.

    php artisan cache:clear or php artisan optimize
    

    Reference
    Post request in Laravel – Error – 419 Sorry, your session/ 419 your page has expired

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search