Masoud Tavakkoli
Masoud Tavakkoli

Reputation: 1020

Sharing session between Laravel and PHP App

I have two app in one server, the first is Laravel based and the second is a pure PHP app.

Now I want to save some variables in the session in laravel and use it in my pure PHP app.

I tried various ways to store session variables but any of them won't worked.

Session::put('key', 'value');

$request->session()->put('key', 'value');

$_SESSION['key'] = 'value';

None of the above storing method allowed me to fetch the session in my pure PHP app.
I print_r($_SESSION) this in pure PHP app and return null.

Upvotes: 2

Views: 1908

Answers (2)

Tai Le
Tai Le

Reputation: 493

I think you forgot using session_start() before use $_SESSION. Please try it.

Upvotes: -1

Anderson Andrade
Anderson Andrade

Reputation: 579

Laravel does not use the Session to save its sessions, it uses, file, cookie, redis or other drives, which is why you can not access directly in $ _SESSION.

https://laravel.com/docs/5.4/session#configuration

Upvotes: 1

Related Questions