PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Above is the php code I have written. It is not showing the desired output. Instead it shows an error as below
"Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\xampp\practice\cookies.php:6) in C:\xampp\htdocs\xampp\practice\cookies.php on line 10" I am a PHP learner. Can any PHP expert help me here.
That's right. Once your script has sent anything to the browser, you cannot use setcookie() function. It must be used before anything like <html>, even a space or a blank line, has been sent. Refer to the manual: http://php.net/manual/en/function.setcookie.php
Califdon is technically correct, but I have found that it doesnt always work well with the design of my code. You can also use output buffering to tackle this problem. Check out the php manual for ob_start()
flying_circus wrote:Califdon is technically correct, but I have found that it doesnt always work well with the design of my code. You can also use output buffering to tackle this problem. Check out the php manual for ob_start()
Thanks, flying_circus, I always forget that, because I seldom use output buffering. Actually, I don't use cookies very much. There are so many things to remember!!