http_cookie_set and http_cookie_remove #2643
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code
2E2B
in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
bool http_cookie_set(string $name, string $value [, array $options])
expires: int, default: 0
path: string, default: ""
domain: string, default: ""
secure: bool, default: false
httponly: bool, default: false
encode: int, default: HTTP_COOKIE_ENCODE_RFC1738
Contants for encode option:
HTTP_COOKIE_ENCODE_NONE (same as setrawcookie)
HTTP_COOKIE_ENCODE_RFC1738 (same encoding as setcookie)
HTTP_COOKIE_ENCODE_RFC3986
If encoding is HTTP_COOKIE_ENCODE_NONE, then no encoding is performed. The caller is responsible for a correct encoding.
If encoding is HTTP_COOKIE_ENCODE_RFC1738, then encoding is performed per RFC 1738 and the application/x-www-form-urlencoded media type, which implies that spaces are encoded as plus (+) signs.
If encoding is HTTP_COOKIE_ENCODE_RFC3986, then encoding is performed according to RFC 3986, and spaces will be percent encoded (%20).
Set cookie with httponly without unnecessary pass the default values for $path, $domain or $secure like setcoookie() or setrawcookie()
Disable encoding and encode the value with another function:
bool http_cookie_remove(string $name);
Remove a cookie. No more need to look into the manual if the correct value is "", NULL or 0 to remove cookies.