PHP header already sent error

Few days ago I made a silly mistake in my php coding. I have echoed something on the page where I have set the cookie.  It seems that it is not faulty code. I googled the problem and found the solution from php.net. Actually cookie must be called before anything goes to browser from server.

So If you echo anything or show anything before setting the cookie, the page will say that cannot modify header. Header already sent by…….. or something like this.

Another silly mistake many of my friend made is that they paste some code before the session_start() function. This should not be done.

Tags:, , ,

This entry was posted on Tuesday, August 25th, 2009 at 11:13 pm and is filed under PHP.

You can follow any responses to this entry through the RSS 2.0 feed.

You can leave a response, or trackback from your own site.

Leave a Reply