Home > Article > Backend Development > lumen error setting cookie
Type error: Argument 1 passed to SymfonyComponentHttpFoundationResponseHeaderBag::setCookie() must be an instance of SymfonyComponentHttpFoundationCookie, string given, called in /data/www/www.test.com/vendor/illuminate/http/ResponseTrait.php on line 83
What caused this error?
Type error: Argument 1 passed to SymfonyComponentHttpFoundationResponseHeaderBag::setCookie() must be an instance of SymfonyComponentHttpFoundationCookie, string given, called in /data/www/www.test.com/vendor/illuminate/http/ResponseTrait.php on line 83
What caused this error?
The error is clear: the parameter is required SymfonyComponentHttpFoundationCookie
but you lost string
The correct usage should be:
<code class="php">use Symfony\Component\HttpFoundation\Cookie; $response->headers->setCookie(new Cookie('foo', 'bar')); </code>