Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Uncaught Error: Call to undefined method Laminas\Http\Header\SetCookie::__toString() #81

Open
kjdfjhdjkh opened this issue Feb 26, 2024 · 2 comments
Labels
Bug Something isn't working

Comments

@kjdfjhdjkh
Copy link

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.

@kjdfjhdjkh kjdfjhdjkh added the Bug Something isn't working label Feb 26, 2024
@laminas-bot
Copy link
Contributor

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.

@Xerkus Xerkus reopened this Feb 27, 2024
@Xerkus
Copy link
Member

Xerkus commented Feb 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants