Auth :: user()不会跨子域传播? -Laravel 5.2 [英] Auth::user() doesn't travel across subdomains? - Laravel 5.2

查看:72
本文介绍了Auth :: user()不会跨子域传播? -Laravel 5.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站中有一个子域,例如:

http://example.ca
http://blog.example.ca

只有拥有URL的人才能访问该Blog,即该URL不是公共知识或常识.我有一堆与此域相关的路由,需要您登录.<​​/p>

我已经在nav.blade.php中指出,如果用户已登录,则应该有一个下拉菜单,如果没有,则应该没有下拉列表.

这一切都对http://blog.example.ca有效,但是当我转到http://example.ca时,我不再通过身份验证.

幼虫中是否有任何方法可以使我在所有子域中通过身份验证?不仅仅是那些具有要求我进行身份验证的控制器操作的人?

解决方案

config/session.php中,您应该更改:

'domain' => null,

进入

'domain' => '.example.ca',

您还应该清除所有cookie

I have a subdomain in my site, for example:

http://example.ca
http://blog.example.ca

The blog one is only accessible to people who have the url, that is, its not public or common knowledge. I have a bunch of routes related to this domain that requires you to be logged in.

I have stated in a nav.blade.php that if the user is logged in, there should be a drop down and if not then there should not be a drop down.

this all works for http://blog.example.ca but when I go to http://example.ca I am not authenticated any more.

Is there any way in larval to make me authenticated across all subdomains? Not just the ones who have controller actions that require me to be authenticated?

解决方案

In config/session.php you should change:

'domain' => null,

into

'domain' => '.example.ca',

You should also clear all the cookies

这篇关于Auth :: user()不会跨子域传播? -Laravel 5.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆