首页 > 解决方案 > Is it possible to get session ID from cookie?

问题描述

I am learning Laravel from few days and am little confused about how the authentication works in Laravel. Where the sessions are stored?

标签: laravelsessionauthentication

解决方案


Getting the Session ID from a cookie?

I wasn't completely sure about what you meant by getting it from a cookie but you could try the code below.

Imports

use Illuminate\Support\Facades\Crypt;

Code

Crypt::decrypt(
  \Request::cookie(
     config('session.cookie')
  )
)

Getting the Session ID

I have not been able to test this but I believe it should work, the 'session()' is a global variable so there's no need for any imports.

Code

$id = session('id');

Hope this answered your question, good luck!


推荐阅读