Published 2 months ago by shahidkarimi
session()->put('currency', $currency); session()->save();
If I immediately dd the session it shows the new value. But in another place, it shows the old value means not saving. I have been facing this issue with every Laravel project.
I tried with all session drivers, redis, array, file and databse. Anybody, please give a permanent solution of this issue.
If you refresh page ???????? Is anything passed to $currency? A modern web app shouldn't be refreshing a page. Rather on each request go through proper view and route to properly pass the necessary data along.
If you are using ajax, DO NOT use session with ajax.
I use sessions often in ver 5.5, and never had a problem.
Once something saved in the session it should be persistent. Yes of course on refreshing it should be there. I am not using ajax. Example: Goto Fiverr.com on the bottom right side there is currency dropdown. Change that and see, the page refreshes and sets that currency in session.
Where is $currency coming from?
I set a search like
And I use it after an edit to return to page I left off on (part of query string). 100% works.
You are some how passing a variable at the wrong time / place, thus the session isn't properly updating.
@topvillas the static method also works 100% for me. Taylor uses __callStatic().
sessions work fine, but only if your code exits normally and runs the terminable middleware. If you dd() in your code then the session is not saved
you should also run
php artisan route:list and check that you have
web against each route, once only per route