Preston Garvey
Preston Garvey

Reputation: 1421

My Laravel 5.4 Logged in User Sessions wont persist

I'm having this weird issue with my app, it can't persist logged in user session using the Auth facade. Example, in my header view I put logged in user data as :

@if (Auth::check())
    <div class="btn-group">
       <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
       <img src="{{route('getphoto', Auth::user()->image)}}" alt="" />
       {{ Auth::user()->name }}
       <span class="caret"></span>
       </button>
     </div>
@else
     <div class="btn-group">
       <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
       Not Logged In
       </button>
     </div>
@endif

At the first time after login the logged in user data in the header like photo and name will be displayed correctly, but after I refresh or moving to another page they disappear and indicate that the user is not logged in. I don't know what I did wrong, all I did with user login related function is just changing the email to username. How do I solve this ? I'm using Laravel 5.4

Upvotes: 3

Views: 303

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163838

You need to set correct permissions for the storage directory:

chmod -R 755 storage

After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server.

https://laravel.com/docs/5.4/installation

Upvotes: 2

Related Questions