Is it OK to send cookie headers directly with header()
calls?
I am tinkering with http cookie mechanism in PHP and would like (at least initially) to try the "raw" thing :)
The Brad Christie's answer to "php-how-to-stringify-array-and-store-in-cookie" assumes it is, but is there a somehow official source on the topic (or is it at least a well-known practice)?
Thanks in advance for clarifying the topic.
[EDIT: AN IMPORTANT NOTICE]
An interesting thing I have discovered is that calling header('Set-Cookie: ...');
effectively prevents any cookies previously supplied with setcookie('...');
from being sent, at least on my machine (PHP 5.3.5, Apache 2.2.17, WinXP SP2). Whether this is a feature / bug(?) or a consequence of PHP semantics/rules violation, I don't know.
Analyzing PHP .c
sources will possibly bring an answer (one should posibly look into head.c
(header()
, setcookie()
, etc) and mod_php5.c
(Apache module) files for that).