0

I am using laravel 7 and keep having this issue in my form:

<form class="form-inline " role="form" method="POST" action="{{route('auth.signup')}}">

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

       <div class="form-group">
            <input type="email" class="form-control" id="inputEmail" name="email" value="email">
        </div>


         <div class="form-group">
           <input type="password" class="form-control" id="password1" name="password">

         </div>

         <div class="form-group">
            <input type="password" class="form-control" id="password2" name="password_confirmation">

        </div>



          <button type="submit" class="btn btn-primary mx-auto">Sign Up</button>

</form>

i already have changed config/session.php This line 'lifetime' => env('SESSION_LIFETIME', 1200),

Is it necessary to show route / controller they all just basic

I have also tried to remove the controller's entire code and simply dd("signed up") but i keep getting the same issues

I also went on to change my php.ini file but the problem persists.

maybe another piece of information to add is that the homepage which has the signup link to the form above also has its own form with a and its not the same token as the one in the form above

The sign up controller:

    public function postSignup(Request $request)

    {
        $this->validate($request,[
        'email'=>'required|unique:appscheduler_users|email|max:255',
        'name'=>'required|max:255',
        'password'=>'required|confirmed|min:6',
        ]);

        $user=user::create([
                    'email'=>$request->input('email'),
                    'name'=>$request->input('name'),
                    'password'=>bcrypt($request->input('password')),
                    'created'=>date('Y-m-d H:i:s'),
                    'ip'=>$request->ip(),
        ]);

        Auth::login($user);
        if(Session::has('oldUrl')) {
            $oldUrl=Session::get('oldUrl');
            Session::forget('oldUrl');
            return redirect()->to($oldUrl);
                }

        return redirect()
                ->route('home')
                ->with('info','Your Account has been created');
    }




Screwtape007
  • 185
  • 1
  • 2
  • 16

1 Answers1

0

To solve this error you first need to insert one of the following commands into the form tag.

@csrf OR {{ csrf_field }}

If your problem is not resolved, do the following: and keep the csrf tag

1.Insert one of the following commands into the form tag @csrf OR {{ csrf_field }}

2.Open the .env file and change the values ​​to the "file" in the SESSION_DRIVER section.

3.Then you should reset laravel cache. type below commands in the terminal

php artisan view:clear php artisan route:clear php artisan cache:clear

php artisan config:cache

4.In the final step, unplug the project from the serve and click again on php artisan serve

I hope your problem is resolved

maybe you wanna take a look here Post request in Laravel - Error - 419 Sorry, your session has expired

RYOK
  • 473
  • 7
  • 23
  • ive already added @CSRF instead of whats on the post above. same issue – Screwtape007 Jun 11 '20 at 19:57
  • ive just done what you suggesting there. my server is on localhost but my db server is an aws RDS instance. not sure that might contribute to the problem. – Screwtape007 Jun 11 '20 at 20:24
  • well to be honest i didn't work with aws before but you might want to try in on localhost first and then if it is working correctly then try it on aws the two most used solutions for this problem are the @csrf directive and changing the session driver to file – RYOK Jun 11 '20 at 20:43
  • i moved to aws because my localhost xampp installation wasnt working. now that im encountering another local server issue im just gonna move it over to my shared hosting server – Screwtape007 Jun 11 '20 at 22:01