Updating cookies

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm trying to implement a 30 day cookie to store a code related to our
affiliate program.  I have this:

$pid = $_GET['PID'];
if (!is_null($pid)) {
     setcookie('PID',$pid, time()+60*60*24*30, "/");
} else $pid = $_COOKIE['PID'];

The idea being, use any PID specified in the URL, overriding any
previous PID set in the cookie.  Otherwise, use the cookie PID.
Unfortunately, the cookie never updates.  I've tried adding this line
before I set the cookie, but it makes no difference:



Re: Updating cookies

Are you sending any other output to the browser before the call to
setcookie()?  Or is the code above the very first thing in your script?
 If it isn't, throw ob_start() at the very top and ob_end_flush() after
you call setcookie().  This might fix the problem.

Site Timeline