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

yogendra's avatar

phpsessid

how we can access phpsessid from laravel like in php $_COOKIE['phpsessid'];

0 likes
4 replies
shakti's avatar

Laravel has its own implementations of $_SESSION and $_COOKIE, so I'm afraid you cannot access them via those superglobals.

To try to overcome that, what you can do, in your Laravel app, is to transfer data from one to the other by doing something like:

foreach(Session::all() $key => $value)
{
    $_SESSION[$key] = $value;
}


yogendra's avatar

when we create ecommerce website ,,user add product to cart with out performing any login just like a guest ,,so how we know which client add that product from his system,,, we must have a unique key to identify.....so in which way how i define that unique id.....i hope you got me.

shakti's avatar

The answer for sessions is so simple Laravel doesn't actually use the $_SESSION at all, it implements a completely different driver.

So, to have acesses to the external session, you just use the native session_start() and session_name() in pure PHP and now you have acess to all data save in the global $_SESSION on the same namespace used in the side project.

hope it might help you

frezno's avatar

every user gets a session, no matter whether he's logged in or not.

So just add the products to the (his) session.

Please or to participate in this conversation.