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

前端 未结 5 1052
悲&欢浪女
悲&欢浪女 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:10

    Laravel has its own implementation of those globals, but you can access them over Symfony request class - which is parent of Laravel request. Symfony is working directly with globals.

    Session:

    Request::getSession();
    

    Cookie:

    $cookie = new ParameterBag($cookie_name);
    

提交回复
热议问题