jeudi 3 septembre 2015

Database variables not getting updated immediately

In my Laravel app (I'm using Laravel 5.1, but this issue exists in Laravel 4 as well), I have a page for "user settings." When a user updates their status from an "undergrad" to a "graduate" student and click "submit", the variable storing this status gets changed in the database.

My app then takes the user to a confirmation page saying their user settings were updated successfully.

However, on that page, I have a condition in the view which determined what menus are next displayed. I have one set of menus for users who are undergrads, and another set of menus for users who are graduate students:

@if(Auth::user()->status == 'graduate')
    @include('graduate_menus')
@else
    @include('undergrad_menus')
@endif 

For some reason, Auth::user still returns the previous value it had stored for the "status" variable. If I click "refresh" on the page, then Auth::user returns the correct value.

I have temporarily fixed the problem by using Javascript to automatically refresh the page once. However, it's an ugly hack and I would like to understand what I am doing wrong that Auth::user is not returning the value that was updated in the previous page's POST and if there is a way to fix it. I think I might have to refresh the Session somehow, but I do not know how. Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1fYh6tG
via IFTTT

Aucun commentaire:

Enregistrer un commentaire