Opened 4 years ago
Last modified 4 years ago
#46550 new defect (bug)
Uncaught TypeError: setcookie() expects parameter 5 to be string, bool given in...
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.2 |
Component: | Bootstrap/Load | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
<?php /** * @since 2.0.0 */ if ( ! defined( 'COOKIE_DOMAIN' ) ) { define( 'COOKIE_DOMAIN', false ); // The value maybe '', not boolean }
Change History (2)
#1
@
4 years ago
- Keywords reporter-feedback added; needs-patch removed
- Severity changed from critical to normal
#2
@
4 years ago
Hello @desrosj,
The function setcookie()
args: http://php.net/setcookie
setcookie ( string $name [, string $value = "" [, int $expires = 0 [, string $path = "" [, string $domain = "" [, bool $secure = FALSE [, bool $httponly = FALSE ]]]]]] ) : bool
The 5th parameter type is string
, but the default constant COOKIE_DOMAIN
type is boolean
.
<?php // So when I code below in my theme/plugin: declare(strict_types = 1); \setcookie( 'name', 'value', \time() + \YEAR_IN_SECONDS, \COOKIEPATH, \COOKIE_DOMAIN // This is not string // \is_bool(\COOKIE_DOMAIN) ? \COOKIE_DOMAIN : '' // I need to code on this way XD );
So I think the default value shall be define( 'COOKIE_DOMAIN', '' );
.
Note: See
TracTickets for help on using
tickets.
Hi @kmvan,
Your ticket is not very detailed. It's impossible to look into this further without more information.
Are you running a single site install or a multisite install? Where is the call to
setcookie()
? Is it in WordPress Core? A plugin? A theme? Please provide more details so that others can reproduce your issue.