2 years ago

laravel 5.3 auth not working on session cookie base

Posted 2 years ago by alirezavalipour93

hi i set my SESSION_DRIVER=file in .env file , user authtication work ok! but when i set SESSION_DRIVER=cookie my authentication not working all the time redirect me to login page here this is my code help me !!

public function userAuth($email = null, $mobile = null, $password)
    $user = new User();
    if (Auth::attempt(['email' => $email, 'password' => $password])) {
        $user = $user->where('email', $email)->first();
        session(['user' => $user]);
    //     dd(session());
        return true;
    } elseif (Auth::attempt(['mobile' => $mobile, 'password' => $password])) {
        $user = $user->where('mobile', $mobile)->first();
        session(['user' => $user]);
        return true;
    } else {
        return false;

this my route:

Route::get('/', '[email protected]')->middleware('auth');

Please sign in or create an account to participate in this conversation.