问题描述
我正在开发一个需要在自定义 php 项目之外工作的 laravel 项目,因为我需要访问 laravel 应用程序中的纯 php 全局变量 $_SESSION 和 $_COOKIE.
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 laravel app.
到目前为止,我得到的只是 null 或空.有人知道怎么做吗?
Until now I'm geting just null or empty. Somebody know how to do that?
推荐答案
Laravel 有自己的 $_SESSION 和 $_COOKIE 的实现,所以恐怕你不能通过这些超全局变量访问它们.
Laravel has its own implementations of $_SESSION and $_COOKIE, so I'm afraid you cannot access them via those superglobals.
为了克服这个问题,您可以在 Laravel 应用程序中执行以下操作,将数据从一个传输到另一个:
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;
}
这篇关于如何从 laravel 应用程序访问全局变量 $_SESSION 和 $_COOKIE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)