PHP Cookie Warning...

Posted by Nano HE on Stack Overflow See other posts from Stack Overflow or by Nano HE
Published on 2010-04-17T10:49:02Z Indexed on 2010/04/17 10:53 UTC
Read the original article Hit count: 251

Filed under:
|

Hi,I am new to PHP, I practised PHP setcookie() just now and failed.

http://localhost/test/index.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>

    </head>
    <body>
     <?php
     $value = 'something from somewhere';

     setcookie("TestCookie", $value);
     ?>
    </body>
</html>

http://localhost/test/view.php

<?php
 // I plan to view the cookie value via view.php
 echo $_COOKIE["TestCookie"];

?>

But I failed to run index.php, IE warning like this.

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\index.php:9) in C:\xampp\htdocs\test\index.php on line 12

I enabled my IE 6 cookie no doubt.

Is there anything wrong on my procedure above? Thank you.

WinXP OS and XAMPP 1.7.3 used.

© Stack Overflow or respective owner

Related posts about php

Related posts about cookies