Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

odlb's avatar
Level 1

Cookie Value (ID) vs Session ID

With sessions, I'm noticing the laravel_session cookie value is a different token value than the session $id provided to me by laravel. But for some strange reason I can't figure out where these two values are linked together, eg, how Laravel knows which internal id is linked to what cookie. Can someone help?

0 likes
6 replies
pmall's avatar

I think it is encrypted in the cookie. So someone stealing your cookie can't steel your session.

1 like
odlb's avatar
Level 1

I essentially want to use the laravel cookie as the auth cookie in other apps (using a shared session database between the two) a single-sign-on type solution. So if what you are saying is correct, if I know the decrypt key I can decrypt it in my other apps? Any idea where I might find that?

odlb's avatar
Level 1

I'm using a .domain.com cookie so I can read the cookie between domains. And both sites are writing sessions to a common table in a shared database. So I think I should be ok. It seems to work, the only issue I have is that laravel gives the user a different ID then the one it uses internally so having the other site be aware of the shared id between both hosts has proven tricky.

I suspect you are right, that laravel is just taking that id and hashing it or encrypting it. I'll need to either figure out a way of disabling the encryption on the id or obviously matching the encryption and the keys for it in my other site.

sohe1l's avatar

I am faced with the same issue... I am trying to get the session id from the larval cookie.

Please or to participate in this conversation.