简体   繁体   English

如何在 Laravel 项目之外获取会话变量/数据?

[英]How to get session variable/data outside of laravel project?

Is there any way to get session variable/data outside of the laravel application?有没有办法在 Laravel 应用程序之外获取会话变量/数据?

I have a project in core php (eg: myproject) directory and now I want to signup/signin from laravel which will be placed in internal directory (eg: myproject/laravel).我在核心php(例如:myproject)目录中有一个项目,现在我想从laravel注册/登录,该项目将放置在内部目录(例如:myproject/laravel)中。 I want to get signed-in user's details through session in myproject directory.我想通过 myproject 目录中的会话获取登录用户的详细信息。

Is there any way/alternate for that?有什么办法/替代方法吗?

You will have to add session_start();你将不得不添加session_start(); in public/index.php on the top.在 public/index.php 的顶部。 After that still need to set your external sessions in the classic way $_['mysession'] = 'something';之后仍然需要以经典方式设置您的外部会话$_['mysession'] = 'something'; . . Remember that this will not work if you want to access auth() methods outside Laravel.请记住,如果您想在 Laravel 之外访问 auth() 方法,这将不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM