i’m looking for the way to handle cookies in Symfony 5 … and there is nothing really usefull online.
To set a news cookie, i do :
use SymfonyComponentHttpFoundationCookie;
//.....
$cookie = new Cookie('email', $data['email'] ,time() + (365 * 24 * 60 * 60));
$response->headers->setCookie($cookie);
$response->sendHeaders();
And it works (don’t hesitate to tell me if i’m not using the right way).
My problem appears when i want to get that cookie.
Actually, i do :
$cookie = $request->cookie->get('code_postal');
But i got the following error : "Notice: Undefined property: SymfonyComponentHttpFoundationRequest::$cookie"
Can you help me on that ?
Thank you.
Source: Symfony Questions
Was this helpful?
0 / 0