Answer the question
In order to leave comments, you need to log in
How to store city name in Cookies?
Good afternoon, I just started to master Laravel and faced such a problem.
The user opens the site, selects his city. I write the city name in Cookies via @php in the Blade template. We get a link to a site like this: site.ru/moscow. Everything works great, but... if you change the city to another one (for example, Omsk), then all links on the site lead to the previous selected city (site.ru/moscow), and not site.ru/omsk.
I want to replace that the page immediately after clicking is reloaded and Cookies are updated. There is a suspicion that somehow the Blade template is loading faster than the Cookies are updated.
I suspect that this way of remembering the user's city is bad, maybe there are other not very complicated options?
Answer the question
In order to leave comments, you need to log in
>There is a suspicion that somehow the Blade template is loading faster than the Cookies are updated.
Actually, yes, the cookie is updated when a response is received from the server, and the server draws the page based on the already sent cookie. Option one: redirect to the same page to process the request with a new cookie. Option two: to create links, use the value from the request or from the cookie, if there is no such value in the request.
The user opens the site, selects his city.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question