The issue here is, that cookies must be set, befor any additional header is beeing send to the browser, it's even mentioned in teh description of
setcookie()
Quote:
|
Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace. If output exists prior to calling this function, setcookie() will fail and return FALSE. If setcookie() successfully runs, it will return TRUE. This does not indicate whether the user accepted the cookie.
|