setrawcookie

FunctionParams and return types changed in PHP 8.0

Send a cookie without urlencoding the cookie value.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

setrawcookie Function synopsis

setrawcookie(
    string $name,
    string $value = "",
    array|int $expires_or_options = 0,
    string $path = "",
    string $domain = "",
    bool $secure = false,
    bool $httponly = false
  ): bool

Parameters

$name

Typestring

$value

OptionalTypestringDefault value""

$expires_or_options

OptionalTypearray|intDefault value0

$path

OptionalTypestringDefault value""

$domain

OptionalTypestringDefault value""

$secure

OptionalTypeboolDefault valuefalse

$httponly

OptionalTypeboolDefault valuefalse

Return value

Typebool

Returns true on success, false on failure

Changes to the setrawcookie Function

PHP 8.0

  • Return type added: bool
  • Parameter type added for parameter #1 ($name): string
  • Parameter type added for parameter #2 ($value): string
  • Parameter default value added for position #2 ($value): ""
  • Parameter type added for parameter #3 ($expires_or_options): array|int
  • Parameter default value added for position #3 ($expires_or_options): 0
  • Parameter type added for parameter #4 ($path): string
  • Parameter default value added for position #4 ($path): ""
  • Parameter type added for parameter #5 ($domain): string
  • Parameter default value added for position #5 ($domain): ""
  • Parameter type added for parameter #6 ($secure): bool
  • Parameter default value added for position #6 ($secure): false
  • Parameter type added for parameter #7 ($httponly): bool
  • Parameter default value added for position #7 ($httponly): false
  setrawcookie(
-     $name,
+     string $name,
-     $value,
+     string $value = "",
-     $expires_or_options,
+     array|int $expires_or_options = 0,
-     $path,
+     string $path = "",
-     $domain,
+     string $domain = "",
-     $secure,
+     bool $secure = false,
-     $httponly
+     bool $httponly = false
-   )
+   ): bool

PHP 7.3

  • Parameter name of parameter #3 changed: $expires to $expires_or_options
  setrawcookie(
      $name,
      $value,
-     $expires,
+     $expires_or_options,
      $path,
      $domain,
      $secure,
      $httponly
    )

PHP 5.5

  • Optional parameter added - #7: $httponly
 setrawcookie(
     $name,
     $value,
     $expires,
     $path,
     $domain,
-    $secure
+    $secure,
+    $httponly
   )

setrawcookie Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes