Laravel子域丢失重定向会话

时间:2016-05-01 14:56:22

标签: php laravel subdomain

我使用子域通配符来创建用户特定页面,例如{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'
    ]);
});

1 个答案:

答案 0 :(得分:2)

这是因为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,

您需要将此值设置为包含所有子域的内容。

https://serverfault.com/questions/153409/can-subdomain-example-com-set-a-cookie-that-can-be-read-by-example-com