I am learning php. I followed the example codes from php manual, but it gives me this warning.
<?php
    $value = 'something from somewhere';
    setcookie("TestCookie", $value);
    setcookie('TestCookie', $value, time() + 3600);
    setcookie("TestCookie", $value, time() + 3600, "/~rasmus/", "example.com",1);
?>
The cookies have been set.
<?php 
    echo 'part 1';
    echo $_COOKIE["TestCookie"];
    echo 'part 2';
    echo $HTTP_COOKIE_VARS['TestCookie'];
    echo 'part 3';
    print_r($_COOKIE);
?>
but the output gives me this warning. Any one can help ? Thanks !
( ! ) Warning: Cannot modify header information - headers already sent by (output started at /home/tqjustc/Documents/Workspace/PHP/public_html/demo_PHP/demo1.php:2) in /home/tqjustc/Documents/Workspace/PHP/public_html/demo_PHP/demo1.php on line 5
Call Stack
#   Time    Memory  Function    Location
1   0.0001  631440  {main}( )   ../demo1.php:0
2   0.0001  632176  setcookie ( )   ../demo1.php:5
( ! ) Warning: Cannot modify header information - headers already sent by (output started at /home/tqjustc/Documents/Workspace/PHP/public_html/demo_PHP/demo1.php:2) in /home/tqjustc/Documents/Workspace/PHP/public_html/demo_PHP/demo1.php on line 6
Call Stack
#   Time    Memory  Function    Location
1   0.0001  631440  {main}( )   ../demo1.php:0
2   0.0002  632256  setcookie ( )   ../demo1.php:6
( ! ) Warning: Cannot modify header information - headers already sent by (output started at /home/tqjustc/Documents/Workspace/PHP/public_html/demo_PHP/demo1.php:2) in /home/tqjustc/Documents/Workspace/PHP/public_html/demo_PHP/demo1.php on line 7
Call Stack
#   Time    Memory  Function    Location
1   0.0001  631440  {main}( )   ../demo1.php:0
2   0.0002  632624  setcookie ( )   ../demo1.php:7
The cookies have been set. part 1part 2part 3Array ( [PHPSESSID] => 81990884013fa394c95c38b7f6aeac6e ) 
 
     
    