Quynh Nguyen
Quynh Nguyen

Reputation: 3009

Share auth sessions across sub domains with multiple Laravel 5 project

Current system:

.ENV setting:

APP_KEY=base64:tRpczdAlZ3jZ5VbP4sBU6BJcltftB5pBFpOuHbh/pq4=

SESSION_DRIVER=cookie

SESSION_DOMAIN=foo-bar.dev

config/app.php setting:

'cookie' => 'laravel_session'

Now I can login from Laravel 5.2 and can use that cookies for Laravel 5.3 but can't opposite.

I had try to change SESSION_DRIVER=cookie => database but get same result.

Upvotes: 6

Views: 1741

Answers (1)

CUGreen
CUGreen

Reputation: 3184

With this situation, I am pretty sure you have to prepend the dot on your cookie domain. eg:

SESSION_DOMAIN=.foo-bar.dev

Give it a go, see if it works.

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

Upvotes: 3

Related Questions