[wp-trac] [WordPress Trac] #46550: Uncaught TypeError: setcookie() expects parameter 5 to be string, bool given in...

WordPress Trac noreply at wordpress.org
Mon Mar 18 14:26:20 UTC 2019


#46550: Uncaught TypeError: setcookie() expects parameter 5 to be string, bool
given in...
-------------------------------+------------------------------
 Reporter:  kmvan              |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Bootstrap/Load     |     Version:  trunk
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by kmvan):

 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
 <?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', '' );`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46550#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list