1

Auth controller keeps redirecting me back to home page. A Session is setting fine. I am using cookies as the driver.

A Session Cookie is being set, but Session Storage, viewed with Chrome Developer Tools, is empty.

It redirects fine, if I comment out the redirect()->guest('/'); in middleware. It means that it keeps authenticating as guest and if I var_dump(Auth::user()); I get NULL.

panther1
  • 115
  • 9
  • check [here](http://stackoverflow.com/questions/34548061/laravel-5-2-auth-not-working/34548115#34548115) – Moppo Apr 04 '16 at 13:51
  • ^ already using the middle-ware 'web'. Before, using the web middle-ware, session cookie was not being set. However, this problem is solved now. Still, for some reason, the session doesn't seem to be persisting. – panther1 Apr 04 '16 at 14:00
  • What exactly Laravel version do you use? – Alexey Mezenin Apr 04 '16 at 14:15

1 Answers1

0

Maybe you need this. I answered it in another question here:

Laravel 5.2 - Every route redirects to the homepage

Community
  • 1
  • 1
  • I have a redirect route defined in auth controller. The redirect works fine, however, the session is not persisting. It considers the user as guest and redirects him back to homepage. If I disable the guest redirection, it redirects fine to my dashboard. However, in that case there is no session, because the user is guest. – panther1 Apr 04 '16 at 14:36
  • I meant this comment: " Try to add this in every controller you have: public function __construct() { $this->middleware('auth'); } " – Sladjan Marjanovic Apr 04 '16 at 14:40
  • Maybe you didnt used middleware in a proper way: Route::group(['middleware' => 'web'], function () { // put your routes here }); – Sladjan Marjanovic Apr 05 '16 at 11:32