Search code examples
laravelsessionmobile-safarilaravel-10

Remember login using laravel auth login failed only on mobile-Safari


I made a website support google login, and when success callback, using Auth::loginUsingId(user_id,true), so the user can login again even browser close, and the whole login process works fine on chrome but failed on mobile Safari.

I tried regular login request, using Auth:attempt([credentials],true), and user can login again even browser close on mobile Safari

if ($google_user) {
    $app_user = $google_user->appUser;
    if ($app_user) {
        Auth::loginUsingId($app_user->id, true);
        return redirect('/');
    } 
}

if (Auth::attempt($this->only('email', 'password'), true)) {
    return redirect('/');
}

Solution

  • After I remote debug safari, I found that there will same name cookies for session in similar domain, example.com and [www].example.com.

    Then I went to google clould console, using example.com for url and it's works.