F
F
freeeeez2017-06-05 12:25:14
HTTP Cookies
freeeeez, 2017-06-05 12:25:14

How to set cookie before sending response in Laravel?

When visiting the site for the first time, the user is set a cookie ('city') with the value of his city, determined by IP. And at the same time, this city should be displayed on the site. But when you try to display the cookie, an error occurs and the city appears only after the page is reloaded. How can I make the first visit to the site set a cookie at the same time and, when loading the main one, already substitute the value in the page code? How can I do this so that when viewing any page, a cookie is set? I just added the installation code to routes.php, but maybe there is some other way

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-06-05
@freeeeez

Cookie::queue($name, $value, $expires)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question