-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Cookie with string type field expire #19917
Comments
Could you please clarify what you mean with that? |
I wrote this for a better understanding of the code I wrote. To not reveal the name of cookie, I use cookie_name. So, first of all, Clients have cookie, with name cookie_name, which helps us to classify users by subscription type. I hope, this is enough, but I think this is not about the case. This case is about Cookie object initialization, where expire value is set with string, not with timestamp. |
I wonder how this happens since PHP should change the time string to unix timestamp internally... |
Thanks for the explanation, but for me it's still unclear what "auth service" is? And where |
It is
|
Looks like PHP behaves the opposite, from the docs:
|
@hukimato |
Things get even more weird: echo setcookie('test', 'value', 'Sat, 27 Jan 2024 11:39:10 GMT') ? 'y' : 'n';
@bizley So your statement that it's automatically converted is correct when using PHP 7.4 |
PR that broadens the accepted types for |
I made request to auth service and got cookie from it.
I supposed to set this cookie to client:
Yii::$app->response->cookies->add($response->cookies->get('cookie_name'));
But this code will generate exception.
I found out, that cookie returned by get method returned object with string type of expire value:
Of course it was easily fixed by
$cookie = $response->cookies->get('cookie_name');
$cookie->expire = strtotime($cookie->expire);
But class Cookie has phpdoc comment, that type of this field supposed to be integer.
Yii version 2.0.4
PHP version php7.2-fpm
Operating system Ubuntu 20.04.6 LTS Linux 5.4.0-155-generic x86_64
The text was updated successfully, but these errors were encountered: