how can I set cookies in the middle of a document, without incurring a ‘headers already sent’ error? What I’m trying to do is make a log out script (the log in cookie setting works…so odd. Is it because it’s enclosed in an if statement?) however I’ve already echoed the page title and some other stuff at the top of the page, before I’ve made this logout happen.
Thanks!
The easiest way is to use output buffering to stop PHP from sending data to the client until you’re ready
Output buffering stores all outputted data until the buffer is flushed, and then sends it all at once, so any echos after the
startwill remain buffered until theend_flushand then sent