简体   繁体   English

Laravel 5.2登录路由/会话问题

[英]Laravel 5.2 Login route / Session issue

Nearly finished my first Laravel project and have encountered this odd issue. 我的第一个Laravel项目几乎完成,并且遇到了这个奇怪的问题。 My auth works fine except for one thing. 我的认证工作正常,除了一件事。 I have links to register and login at the top of my welcome page. 我的欢迎页面顶部有注册和登录的链接。 Those work fine. 那些工作正常。 When I log out I am taken back to the welcome page, which is perfect. 当我注销时,我将返回到欢迎页面,这是完美的。 However, once back to the welcome page I am unable to use the Register or Login links. 但是,回到欢迎页面后,我将无法使用“注册”或“登录”链接。 They simply reload the welcome page when clicked. 他们只要单击即可重新加载欢迎页面。 The HTML when I view source on the welcome page still shows the correct routes to Register and Login, and can still access the protected parts of the site by entering the URL. 当我在欢迎页面上查看源代码时,HTML仍显示正确的注册和登录路径,并且仍然可以通过输入URL来访问网站的受保护部分。 So clearly my session is not ending upon logout. 很明显,我的会话并没有在注销后结束。 Any tips on how to address this? 有关如何解决此问题的任何提示?

Its probably because you are actually still logged in. The 'welcome' page does not by default have the 'web' middleware applied. 这可能是因为您实际上仍在登录。默认情况下,“欢迎”页面未应用“网络”中间件。 When on the 'welcome' page it will always think you are not authenticated because there are no sessions, so there is never a user available to check auth against. 在“欢迎”页面上时,它总是会认为您没有通过身份验证,因为没有会话,因此永远不会有用户可以检查身份验证。

Update 更新资料

You may want to check what method your logout route is pointing to on the AuthController. 您可能需要检查AuthController上的注销路由指向哪种方法。 The guest middleware is applied to all the routes except for the logout method. 访客中间件将应用于除logout方法之外的所有路由。 You may have your route pointing to the getLogout , which would cause you to get redirected to '/' instead of being logged out and then redirected. 您的路由可能指向getLogout ,这将导致您重定向到'/'而不是先注销然后重定向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM