Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

omontes's avatar

Get session from another project

situation:

project 1 / app ...

project 2 / app ...

In the project one of the varaibles are created session (Session :: put ('user', $ user);)

get {{Session session :: get ('user')}} from the project2

0 likes
5 replies
bashy's avatar

Store the session (/config/session.php) in a common folder you can get to them from each app. If you're using the same database, use database as session driver. You can also use a different driver so you can get them via the same service.

omontes's avatar

I use redis (/config/session.php)

'driver' => 'redis', 

in project 2

{{ Session::get('user') }} 

I get nothing

rodrigo.pedra's avatar

As I replied in [ https://laracasts.com/discuss/channels/general-discussion/carry-authenticate-from-one-site-to-another?page=1#reply-44774 ]

It works if you are using the same storage for session management for both apps (redis, memcached, shared session folder, ...)

If they are all in the same server it should work if 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. Actually I tested locally and it worked.

But it does not seem to be a good idea from a security point of view.

bashy's avatar

Yup, does work, I've already stated what they need to do :)

Please or to participate in this conversation.