问题
I have a shared server for several Laravel
projects. Example:
x.x.x.x/project1
x.x.x.x/project2
My problem is that when I try to login in project1
, project2
will automatically logout. Is it because of Laravel
sessions?
Could someone suggest what I should do?
回答1:
The path of the session cookie is configurable. Take a look at the path
key in config/session.php
回答2:
This is not a session issue, but a cookie issue.
You can fix APP_NAME
in your .env
file differently for each project.
This is because of the cookie configuration part of the session.php file.
'cookie' => env(
'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
),
回答3:
I changed the session cookie identifier to add the environment, so I could have a dev and live site open in the same browser at the same time. Here is the code I replaced in config/session.php for the cookie:
'cookie' => env(
'SESSION_COOKIE',
str_slug(env('APP_NAME', 'laravel'), '_').env('APP_ENV','dev').'_session'
),
来源:https://stackoverflow.com/questions/32647464/session-conflicts-with-multiple-laravel-projects-on-one-server