alex.hughson Posted June 19, 2008 Share Posted June 19, 2008 I wrote a function to check valid cookies on my site, and have it on its own in a .php file when I try to include the file, then call the function, I get an error "Cannot modify header information output started at..." and then a bunch of things about how the output was started in my include file. I wrote it with the assumption that include was like copying the contents of the included file in at that point. and when i do a setcookie at the same place within the page, nothing bad happens. Anybody have an idea how to fix this? I need to use the include file in a bunch of pages in the site. Thanks -Alex Link to comment https://forums.phpfreaks.com/topic/110837-setcookie-in-include-file/ Share on other sites More sharing options...
hitman6003 Posted June 19, 2008 Share Posted June 19, 2008 http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Link to comment https://forums.phpfreaks.com/topic/110837-setcookie-in-include-file/#findComment-568657 Share on other sites More sharing options...
Stephen Posted June 19, 2008 Share Posted June 19, 2008 You have to make sure it sets the cookie before any output is done (i.e. an echo or HTML). I had this problem before: I was using UTF-8 or whatever encoding and it made a character at the top that I didn't see. After I deleted that character it worked (just switch to ANSI encoding). Link to comment https://forums.phpfreaks.com/topic/110837-setcookie-in-include-file/#findComment-568716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.