【问题标题】:How to send the auth cookie in the response body with Laravel?如何使用 Laravel 在响应正文中发送 auth cookie?
【发布时间】:2015-04-18 16:07:44
【问题描述】:

我使用的是 Laravel 4.2,我需要在登录请求的响应中发送 auth cookie。

到目前为止,我尝试了Cookie::get('laravel_session'),但这只会返回客户端发回的cookie。

if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password')))) {
    /* I need the auth token here */
}

想法?

【问题讨论】:

    标签: php authentication laravel cookies laravel-4


    【解决方案1】:

    这样就可以了:Session::getId()

    在这里找到:How can I get the session ID in Laravel?

    这实际上做得很好:

    Crypt::encrypt( Session::token() )
    

    【讨论】:

      猜你喜欢
      • 2016-12-25
      • 1970-01-01
      • 2015-06-06
      • 2013-09-27
      • 2018-08-19
      • 2018-06-06
      • 2014-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多