laminas-http
laminas-http copied to clipboard
PHP Fatal error: Uncaught Error: Call to undefined method Laminas\Http\Header\SetCookie::__toString()
Bug Report
Q | A |
---|---|
Version(s) | 2.19.0 |
Summary
When attempting to serialize the cookies using the documentation on the /laminas-http/client/cookies/#serializing-and-caching-cookies page, I get the following error:
PHP Fatal error: Uncaught Error: Call to undefined method Laminas\Http\Header\SetCookie::__toString()
on Line 270 of /laminas/laminas-http/src/Cookies.php
How to reproduce
Code:
$client = new Client();
$headers = $client->getRequest()->getHeaders();
$cookies = new Laminas\Http\Cookies($headers);
$client->setUri(_redacted_);
$client->setParameterPost(['login' => '_redacted_', 'pwd' => '_redacted_']);
$client->setMethod('POST');
$response = $client->getResponse();
$cookies->addCookiesFromResponse($response, $client->getUri());
$cookiesToCache = $cookies->getAllCookies($cookies::COOKIE_STRING_CONCAT);
Expected behavior
The $cookiesToCache variable should have the serialized string.
This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering Committee. If you have a security issue, please follow our security reporting guidelines. If you wish to take on the role of maintainer, please nominate yourself
You can continue using laminas/laminas-http safely. Its successor will be PSR-7 in a later revision of laminas/laminas-mvc.
This bug was never discovered and this apparently never worked since call to __toString()
present since 2.0.0 and header never had __toString()
in stable releases.
@kjdfjhdjkh I would recommend to utilize PSR-18 http client instead of this library.