Laravel 子域在重定向时丢失会话
Laravel with subdomain losing sessions on redirect
我使用子域通配符创建用户特定页面,例如 {slug}。mysite.com
用户可能会从 mysite.com 导航到 {slug}。mysite.com
但是我似乎对这两个路由/域有不同的登录会话。
Route::group(['domain' => '{slug}.mysite.com'], function()
{
Route::get('/', 'PagesController@showByUsername');
Route::get('/plans/{plan}', 'PlansController@showslug');
Route::controllers([
'auth' => 'Auth\AuthControllerClient'
]);
});
这是因为 cookie 是特定于子域的。
本文来自config/session.php
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => null,
您需要将此值设置为包含所有子域的值。
我使用子域通配符创建用户特定页面,例如 {slug}。mysite.com
用户可能会从 mysite.com 导航到 {slug}。mysite.com
但是我似乎对这两个路由/域有不同的登录会话。
Route::group(['domain' => '{slug}.mysite.com'], function()
{
Route::get('/', 'PagesController@showByUsername');
Route::get('/plans/{plan}', 'PlansController@showslug');
Route::controllers([
'auth' => 'Auth\AuthControllerClient'
]);
});
这是因为 cookie 是特定于子域的。
本文来自config/session.php
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| Here you may change the domain of the cookie used to identify a session
| in your application. This will determine which domains the cookie is
| available to in your application. A sensible default has been set.
|
*/
'domain' => null,
您需要将此值设置为包含所有子域的值。