簡體   English   中英

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,

您需要將此值設置為包含所有子域的值。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM