Hello,
I've recently started learning PHP and have a question.
I tried running below script which can be found at
http://se2.php.net/manual/sv/function.setcookie.php
but I keep getting this message on my browser, why?
Warning: Cannot add header information - headers already sent by
(output started at /var/www/cookietest.php:2) in
/var/www/cookietest.php on line 6
Warning: Cannot add header information - headers already sent by
(output started at /var/www/cookietest.php:2) in
/var/www/cookietest.php on line 7
Warning: Cannot add header information - headers already sent by
(output started at /var/www/cookietest.php:2) in
/var/www/cookietest.php on line 8
-----
<?
echo "Setting cookie";
$value = 'Test value';
setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
setcookie("TestCookie", $value, time()+3600, "/~rasmus/",
".example.com", 1);
echo "Cookie Set!";
?>