How to use same session on two laravel project?

by aniya.jaskolski , in category: PHP Frameworks , a year ago

How to use same session on two laravel project?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by darrion.kuhn , a year ago

@aniya.jaskolski 

To use the same session on two Laravel projects, you can follow these steps:

  1. Set the same session domain for both projects in the session configuration file (config/session.php). This can be done by setting the 'domain' key to the same value in both projects.
1
'domain' => env('SESSION_DOMAIN', 'yourdomain.com'),


  1. In each project, set the same value for the 'APP_KEY' in the .env file. This will ensure that the encryption key used for the session data is the same in both projects.
1
APP_KEY=yourappkey


  1. Make sure that both projects are using the same session driver and configuration settings. This can be checked and configured in the session configuration file (config/session.php).
1
2
3
'driver' => 'file',
'lifetime' => 120,
'expire_on_close' => true,


  1. After making these changes, you should be able to share the same session between the two Laravel projects. Users who are authenticated in one project should also be authenticated in the other project.


Note: It is important to keep in mind the security implications of sharing session data between multiple projects. Make sure that both projects are hosted on secure servers and that you are not sharing sensitive data in the session.

Related Threads:

How to get number of session in laravel project?
How to use redis as session caching in laravel?
How to separate user session from admin session in laravel?
How to use nuxt.js components in a wordpress project?
How to deploy react/laravel project?
How to redirect urls in a laravel project?