session_set_cookie_params
Function • Params and return types changed in PHP 8.0
Set the session cookie parameters.
session_set_cookie_params Function synopsis
session_set_cookie_params(
array|int $lifetime_or_options,
?string $path = null,
?string $domain = null,
?bool $secure = null,
?bool $httponly = null
): bool
Parameters
$lifetime_or_options
Typearray|int
When using the first signature, lifetimeof the
session cookie, defined in seconds.
$path
OptionalType?stringDefault valuenull
Path (session.cookie_path) on the domain where
the cookie will work. Use a single slash ('/') for all paths on the
domain.
$domain
OptionalType?stringDefault valuenull
Cookie domain for
example 'www.php.net'. To make cookies visible on all subdomains then
the domain must be prefixed with a dot like '.php.net'.
$secure
OptionalType?boolDefault valuenull
If true cookie will only be sent over
secureconnections.
$httponly
OptionalType?boolDefault valuenull
If set to true then PHP will attempt to send the
httponly flag when setting the session cookie.
Return value
Typebool
Returns true on success, false on failure
Changes to the session_set_cookie_params Function
PHP 8.0
- Return type added:
bool - Parameter type added for parameter #1 (
$lifetime_or_options):array|int - Parameter type added for parameter #2 (
$path):?string - Parameter default value added for position #2 (
$path):null - Parameter type added for parameter #3 (
$domain):?string - Parameter default value added for position #3 (
$domain):null - Parameter type added for parameter #4 (
$secure):?bool - Parameter default value added for position #4 (
$secure):null - Parameter type added for parameter #5 (
$httponly):?bool - Parameter default value added for position #5 (
$httponly):null
session_set_cookie_params(
- $lifetime_or_options,
+ array|int $lifetime_or_options,
- $path,
+ ?string $path = null,
- $domain,
+ ?string $domain = null,
- $secure,
+ ?bool $secure = null,
- $httponly
+ ?bool $httponly = null
- )
+ ): bool PHP 7.3
- Parameter name of parameter #1 changed:
$lifetimeto$lifetime_or_options
session_set_cookie_params(
- $lifetime,
+ $lifetime_or_options,
$path,
$domain,
$secure,
$httponly
) session_set_cookie_params Function Availability
session_set_cookie_params Function Availability| PHP Version | Availability |
|---|---|
| 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 |