Answer the question
In order to leave comments, you need to log in
Why does the session check in the middleware return false, while in the template it returns true?
It is not necessary to register on the site, but it is very important to know the user's city in order to provide relevant content.
Therefore, in the global middleware, I define the city using https://api.sypexgeo.net/json/
, look for it in the database and fix it in the session: Session::put('city', $city)
In order not to send repeated requests to api.sypexgeo.net, I check before it: if (!Auth::check() && !session()->has('city')) {}
And it turned out that the session always returns false here, as if it is not open session with the city, but when I check in the template, the check for the presence of the session returns true.
How then to solve this problem?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question