简体   繁体   中英

Laravel 5.2 Login route / Session issue

Nearly finished my first Laravel project and have encountered this odd issue. 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. 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. The guest middleware is applied to all the routes except for the logout method. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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