如何使用 Laravel 在响应正文中发送身份验证 cookie?
How to send the auth cookie in the response body with Laravel?
我正在使用 Laravel 4.2,我需要在对登录请求的响应中发送身份验证 cookie。
到目前为止,我尝试了 Cookie::get('laravel_session')
但那只会 return 客户端发回的 cookie。
if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password')))) {
/* I need the auth token here */
}
想法?
这将完成:Session::getId()
在这里找到了:How can I get the session ID in Laravel?
这个其实做的不错:
Crypt::encrypt( Session::token() )
我正在使用 Laravel 4.2,我需要在对登录请求的响应中发送身份验证 cookie。
到目前为止,我尝试了 Cookie::get('laravel_session')
但那只会 return 客户端发回的 cookie。
if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password')))) {
/* I need the auth token here */
}
想法?
这将完成:Session::getId()
在这里找到了:How can I get the session ID in Laravel?
这个其实做的不错:
Crypt::encrypt( Session::token() )