-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Make array value cookies able to be sent. #11209
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,15 @@ public function getName(); | |
| */ | ||
| public function getValue(); | ||
|
|
||
| /** | ||
| * Gets the cookie value as a string. | ||
| * | ||
| * This will collapse any complex data in the cookie with json_encode() | ||
| * | ||
| * @return string | ||
| */ | ||
| public function getStringValue(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason not to use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cookies have more properties than just the value. Wouldn't the string value of a cookie include the Secure, HttpOnly, Path and Domain bits?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, you're absolutely right! Disregard :) |
||
|
|
||
| /** | ||
| * Create a cookie with an updated value. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied your fix and it correctly save the cookie now.
However when I read the cookie value, it continues to be in json format.
Can be correct to modify here like this?
But also when using
ServerRequest->getCookie($cookie_name);it returns the cookie value in json format and it doesn't callCookie->getValue().Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By setting
There are warnings in the
EncryptedCookieMiddlewareso it's more complicated than this 😅Also if you have the
EncryptedCookieMiddlewareactive it already return the value in array format without the need to modifygetValue()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value of the cookie is the JSON data though when you're reading from a request. The cookie middleware adds more behavior to cookies though. I wouldn't recommend people store JSON data in plaintext cookies as its full of 💣