D
D
Div-Man2018-10-20 19:04:43
Laravel
Div-Man, 2018-10-20 19:04:43

Why are cookies not being read?

I don't understand why the cookies I set are not being read?
Added city cookie with value 4019 via JS
Now I'm trying to get this cookie

public function index(Request $request)
    {
        dd($request->cookie('city'));

Displays null, although it exists
5bcb519806233559843703.jpeg
And if you receive XSRF-TOKEN or laravel_session cookies, then they are displayed
if you do this, then it displays, but it's probably wrong to do this in Laravel So also null
dd($_COOKIE['city']);
se Illuminate\Http\Response;
 
public function index(Request $request)
    {
     
         $minutes = 60;
        $response = new Response('Set Cookie');
        $response->withCookie(cookie('name', 'MyValue', $minutes));
     
        dd($request->cookie('name'));

I did it according to the manual, they do not appear either
Cookie::queue(Cookie::make('name222', 'value', 11));
Cookie::queue('name222', 'value', 11);

And so they don't appear And it doesn't display errors If you look at all cookies Then it displays array:3 [▼ "city" => null "XSRF-TOKEN" => "fWOw17uJxrzyb0O5S1uFFTrIVlgACGCqumwUKBy4" "laravel_session" => "GuFcX0OXBJmJJmzmnBCLdmgWsnJymcfSHGPQzMKV" ]
$cookie = cookie('name', 'value', 111);
dd($request->cookie());

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2018-10-20
@Div-Man

You need to read the documentation , it was written for this. And you don't have to be afraid to look into the code .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question