lundi 24 septembre 2018

Laravel - CSRF is not matching with session token

I am tyr to submit one form and login one user all it seems fine in localhost but when I upload these code on live server then the Token is not workingI have check that the CSRF token and Session token value is not same.

Also the post request is not working so I have added the route in except VerifyCsrfToken now the post request is working but after login the user session is not working

if (Session::token() != $request->get('_token'))
{
   echo 'Not Match';exit;
}

Above result show me no match

I have regenerated the Key on server also I had provided the permission to storage folder. Cache data has been cleared but the authectioncation is not working it doesn't work

<form class="login-form js-login-frm" role="form" method="POST" action="">
    
    <div class="form-body">
        <div class="row">
            <div class="col-xs-12">
                <div class="form-group">
                    <div class="input-group" title="">
                        <span class="input-group-addon"><i class="fa fa-envelope-o"></i></span>
                        <input class="form-control" autofocus type="text" id="email_address" placeholder="" name="login"/>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <div class="input-group" title="">
                        <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                        <input class="form-control" id="password" type="password" placeholder="" name="password"/>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="form-actions">
        <button class="btn-del btn-5 btn-5a fa fa-lock login-btn" type="submit" id="login_btn">
            <span></span>
        </button>
    </div>
</form>

In My controller

$remember = $request->remember ? true : false;
$auth = Auth::guard('web')->attempt([
  'email' => $request->login,
  'password' => $request->password,
  'is_active' => 1
], $remember);

This code is working fine but the user didn't redirect to dashboard page it redirect to login page again.

Can anyone help with the login the user in the system. and redirect to porper route.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire