Here's a short code snippet :

$cookie_name = "logged_in";
$cookie_value = "ok";
$cookie_expire = "";
$cookie_domain = "";

setcookie($cookie_name, $cookie_value, $cookie_expire, "/", $cookie_domain, 0);

Standard stuff, right? But all of a sudden, when I run this script, I get the following error :

Warning: setcookie() expects parameter 3 to be long, string given in c:\program files\apache group\apache\htdocs\website\index.php on line xx.

Been staring at this for 2 days now. I haven't seen this error show up before. What am I missing here?? I just want the cookie to last per session, that's all.

p.s. I'm running Apache 1.3, with PHP 4.3.6 on a Win XP platform.

    The manual page for "setcookie()" says:

    Because the expire argument is integer, it cannot be skipped with an empty string, use a zero (0) instead.

      Now I am wondering how all the millions of other examples I've seen in the tutorials got away with that one?! Must be something new in the manual?

      Here's another oddity I found while doing a search in the on-line manual on the function "setcookie" :

      Sorry, but the function setcookie is not in the online manual. Perhaps you misspelled it, or it is a relatively new function that hasn't made it into the online documentation yet. 😕

      Ah, I don't think so.

        Not in the manual? Ya nibblin my banana, ain't cha?

        http://uk.php.net/setcookie

        What the quote installer said means that you can't skip the field with '' and use another one further along, like setting path, either put in zero (making it a session only cookie) or a lifetime.

          The manual kept coming back with that quote. Well, the manual is sometimes screwed in the head too, as we all know. :queasy:

          I'm just wondering how those zillions of examples out there, with a cookie expire time set to "" actually did work in the past. It surely would have saved me posting this question, and two days of dev wonder time.

            Write a Reply...