在子域名之间共享Laravel会话CSRF TOKEN MISMATCH

时间:2016-10-10 14:10:44

标签: php laravel session cookies laravel-5

首先,我已经对这个主题做了很多研究,因为我不想浪费任何人的时间,但我没有找到具体的答案。

我需要在SubDomains之间共享一个laravel会话,这样当用户退出一个SubDomains时,他会退出所有SubDomains。 我目前有两个子域(/ login_master和/ light),并且两个会话文件都配置为使用数据库驱动程序。 这就是他们的样子:

 'driver' => env('SESSION_DRIVER', 'database'),

/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| Here you may specify the number of minutes that you wish the session
| to be allowed to remain idle before it expires. If you want them
| to immediately expire on the browser closing, set that option.
|
*/

'lifetime' => 30,

'expire_on_close' => false,


 'cookie' => 'laravel_session',

/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The session cookie path determines the path for which the cookie will
| be regarded as available. Typically, this will be the root path of
| your application but you are free to change this when necessary.
|
*/

'path' => '/',

/*
|--------------------------------------------------------------------------
| 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' => env('SESSION_DOMAIN', '.' . $_SERVER['SERVER_NAME'])

我不确定域是否设置正确(现在它看起来像这样“.192.168.1.249”)并且它们都具有相同的cookie名称。 当我尝试登录时,我得到令牌不匹配,甚至很难,我已经将CSRF_FIELD包含在发出请求的表单中。

有人可以对这个问题有所了解吗?

谢谢

0 个答案:

没有答案