[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 527
  • Last Modified:

setcookie problems

I've got the following snippet:

setcookie("applicatieid", $array['applicatie_id'], time()+86400, "/", "", 0);

Now i want to let this cookie expire when the session ends (browser close)... BUT i cannot find a way how to do this.
Beacause when i delete time()+86400, or set it on 0 or true/false it does nothing or give's me an error message:
"Warning: setcookie() expects parameter 3 to be long, string given in /home/www/www.domainname.nl/data/intranet/includes/app_id.php on line 20" where line 20 is:
"setcookie("applicatieid", $array['applicatie_id'], "", "/", "", 0);"

Anybody any idea's?
1 Solution
setcookie("applicatieid", $array['applicatie_id'], 0, "/", "", 0);

do not use "". See http://de3.php.net/set_cookie :
You may also replace an argument with an empty string ("") in order to skip that argument. Because the expire  argument is integer, it cannot be skipped with an empty string, use a zero (0) instead.
php-webdesignAuthor Commented:
see... i was thinking to damn hard :-) thank you (think because i am working on this since 9.00 AM (my time GMT+1))

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now