Php Laravel登录一次并在多个子域中登录
我们的网站是在apache服务器上用Laravel7创建的。 我们有一个应用程序,有3个不同的子域。例如:Php Laravel登录一次并在多个子域中登录,php,laravel,apache,authentication,Php,Laravel,Apache,Authentication,我们的网站是在apache服务器上用Laravel7创建的。 我们有一个应用程序,有3个不同的子域。例如: mainwebsite.com products.mainwebsite.com customers.mainwebsites.com suppliers.mainwebsite.com 子域的设置方式如下: Route::domain('supplier.mainwebsite.com')->group(function () { Route::get('/da
mainwebsite.com
products.mainwebsite.com
customers.mainwebsites.com
suppliers.mainwebsite.com
子域的设置方式如下:
Route::domain('supplier.mainwebsite.com')->group(function () {
Route::get('/dashboard', 'ExampleController@show')->name('example-show')->middleware('auth','isActive','role:supplier|admin|producer');
});
我们使用空间权限包来检查角色
现在的问题是身份验证。如果用户登录到suppliers.mainwebsite.com,当他们转到mainwebsite.com时,他们应该再次登录。我们希望他们登录到所有子域。因为有些页面相似,但根据用户角色显示不同的内容。例如,dashboard位于mainwebsite.com/dashboard中,但如果您已登录到suppliers.mainwebsite,并且有一个指向dashboard的链接,该链接指向mainwebsite.com.dashboard,因为子域不同,他们应该重新登录。我们希望他们保持登录状态
我感谢你的帮助
您好,试试这个
在config/session.php中
'domain'=>env('SESSION_domain',null),
到
'domain'=>env('SESSION_domain','mainwebsite.com'),
或在.env中
SESSION_DOMAIN='.mainwebsite.com',