hostingreviews
New Member
For some I can not set cookies in PHP on one my sites. The error that displays on my web page is:
"Warning: Cannot modify header information - headers already sent by(...)"
This happens when I try to set a cookie, for example, when I use this code:
Can someone tell me what I'm doing wrong?
Thanks
"Warning: Cannot modify header information - headers already sent by(...)"
This happens when I try to set a cookie, for example, when I use this code:
HTML:
<html>
<head><title>cookie</title></head>
<body>
<?php
setcookie('test', 'This is a test', time() + 3600);
if(isset($_COOKIE['test'])){
echo 'The cookie is ' . $_COOKIE['test'];
}
?>
</body>
</html>
Can someone tell me what I'm doing wrong?
Thanks