dongshao8125 2018-03-01 21:20
浏览 358
已采纳

如何在用户登录laravel上保存PassportToken

i make API by laravel passport i wanna save passport token in cookies when login is successful i tried to make this in home controller but it always generate different key

  • 写回答

1条回答 默认 最新

  • dqcz57269 2018-03-01 22:00
    关注

    Have you tried withCookie method of a Response object?

    use Illuminate\Http\Response;
    
    ...
    
    $UserToken = Auth::user()->createToken('MyApp')->accessToken;
    $view = view('Ades Admin.DashBoard');
    $response = new Response($view);
    
    return $response->withCookie(cookie('valid', $UserToken, 10));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?