可以使用2个不同的域名www.4evergaming.com
和www.best4games.com
访问我的Laravel应用程序(这些不是我的实际域名,只是一个例子)
这是我的路线文件的外观
Route::pattern('domain', '(www.4evergaming.com|www.best4games.com)');
Route::domain('{domain}')->group(function ()
{
// Routes here...
})
但是在我的config/session.php
中,我只能拥有一个域...
'domain' => '.4evergaming.com',
我需要为两个域都设置会话cookie,但是我该怎么做呢?还是有某种方法可以跨域复制会话?
答案 0 :(得分:0)
我通过在运行时更改配置来解决了这个问题。
Route::pattern('domain', '(www.4evergaming.com|www.best4games.com)');
Route::domain('{domain}')->group(function ()
{
if (strpos($_SERVER['HTTP_HOST'], 'www.best4games.com') !== false) {
config([ 'session.domain' => 'www.best4games.com' ]);
}
})