简体   繁体   中英

Get session data of another PHP application in Laravel

I have two domain in same hosting one is using Custom PHP and another Laravel 5.4 . I have set some value in session variable using custom PHP using $_SESSION . And Now after login its redirect to laravel . Now my question is how can I get this Session variable inside laravel .

you can use session() helper function. or Session Facade.

suppose you want to put something in session you can use

Session::put('key', 'this is something in session');

if you want to access the same

echo Session::get('key') //outputs this is something in session

Laravel doesn't use native PHP sessions since Laravel 4.1 .

We are no longer using Symfony's (and therefore PHP's) session handling facilities, and are using a custom solution that is simpler and easier to maintain

In Laravel you want to use Session:: facade or session() global helper to work with sessions:

// Saving value.
session()->put('key', 'value');

// Gettinng value.
session('key');

So you cannot access session data from another PHP application,

But you may be able to access the session from another Laravel app if you are using the same storage for session management for both apps ( Redis , Memcached , shared session folder, ...) and you use the same APP_KEY (look in your .env file) and the same cookie identifier (look in your config\\session.php file) in both apps.

您可以使用适当的名称空间\\Session来访问Session外观

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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