setrawcookie()
setrawcookie() — Send a cookie without urlencoding the cookie value.
Built-in function of PHP 8.5. The manual lists it as available in PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
setrawcookie() is exactly the same as setcookie() except that the cookie value will not be automatically urlencoded when sent to the browser.
Signature
setrawcookie(string $name, string $value = ?, int $expires_or_options = 0, string $path = ?, string $domain = ?, bool $secure = false, bool $httponly = false): bool setrawcookie(string $name, string $value = ?, array $options = []): bool
Parameters
This function takes no parameters.
Return value
Returns true on success or false on failure.
Example
The PHP manual ships no example for setrawcookie(); the signature and the parameter table above are the contract.
Changelog
| Version | Change |
|---|---|
| 8.5.0 | The "partitioned" entry was added in the options array. If set to true, the cookie will be marked as Partitioned (CHIPS). |
| 7.3.0 | An alternative signature supporting an options array has been added. This signature supports also setting of the SameSite cookie attribute. |
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page setrawcookie() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.