Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

[PHP] Warning: Cannot modify header information when Create a COOKIE

When you create COOKIE or try to set COOKIE, are you getting error like “Warning: Cannot modify header information – headers already sent” ? This happen if your page starts output on browser. COOKIE is at browser and it will not set if your Browser has started output. Look at below code for better understanding.


Above code will give you Warning because before set cookie, output started on browser with HTML div element. So make sure to set your cookie before browser starts output the data. Look at below code which works perfectly.

Let me Know if you have still problem.
Thank You.

No Comments Yet.

Leave a Reply

Your email address will not be published.