setcookie problems

Posted on 2004-11-17
Last Modified: 2012-06-21
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/ on line 20" where line 20 is:
"setcookie("applicatieid", $array['applicatie_id'], "", "/", "", 0);"

Anybody any idea's?
Question by:php-webdesign
    LVL 48

    Accepted Solution

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

    do not use "". See :
    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.
    LVL 5

    Author Comment

    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

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Upload PDF On Mobile 1 41
    code igniter select query 7 21
    What does this mean? 6 26
    php mysql if then statement syntax 4 11
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now