How to access the globals $_SESSION and $_COOKIE from a laravel app?

前端 未结 5 1055
悲&欢浪女
悲&欢浪女 2020-12-20 14:36

I am working on a laravel project that needs to work besides a custom php project, because that I need to get access to the pure php globals $_SESSION and $_COOKIE in the la

5条回答
  •  情书的邮戳
    2020-12-20 15:06

    The answer for sessions is so simple that I don't believe at the begining that it will actually work.

    I was thinking that Laravel somehow override the default behavior of the normal PHP Sessions. Maybe declaring a custom session_handler or some other magic behind the scenes.

    Thanks for all the answers I got here, I discover that Laravel doesn't actually use the $_SESSION at all, it implements a completely different driver.

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

    For cookies, I can't figure out yet how to do it, from the Laravel app :/. But just with sessions I can go ahead and merge the apps.

提交回复
热议问题