Sharing Subdomain Authentication Sessions with Multiple Laravel 5 Projects

Current system:

  • There are two Laravel projects: 5.2 and 5.3
  • Using the subdomain on local: control.foo-bar.dev (Laravel 5.2) and service.foo-bar.dev (Laravel 5.3)

.ENV:

APP_KEY=base64:tRpczdAlZ3jZ5VbP4sBU6BJcltftB5pBFpOuHbh/pq4=

SESSION_DRIVER=cookie

SESSION_DOMAIN=foo-bar.dev

config / app.php:

'cookie' => 'laravel_session'

Now I can log in from Laravel 5.2 and use these cookies for Laravel 5.3, but I can’t do the opposite.

I tried changing SESSION_DRIVER=cookie => database , but getting the same result.

+6
source share
1 answer

In this situation, I'm sure you need to add a dot to your cookie domain. eg:

SESSION_DOMAIN=.foo-bar.dev

Let him know if he works.

Edit: Also, my 5.2 has a session cookie domain as null , so make sure it's set to 'domain' => env('SESSION_DOMAIN', null), in your config / session.php

+3
source

Source: https://habr.com/ru/post/1014075/


All Articles