[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.