manix Posted July 26, 2011 Share Posted July 26, 2011 Everytime I attempt to delete a cookie or redirect I get this error Warning: Cannot modify header information - headers already sent by (output started at path.php:line) in path.php on line x Quote Link to comment https://forums.phpfreaks.com/topic/242867-cookie-error/ Share on other sites More sharing options...
AyKay47 Posted July 26, 2011 Share Posted July 26, 2011 no output can be sent to the browser before calling setcookie(), there is a sticky about it in this section Quote Link to comment https://forums.phpfreaks.com/topic/242867-cookie-error/#findComment-1247460 Share on other sites More sharing options...
manix Posted July 26, 2011 Author Share Posted July 26, 2011 I know, but I don't have any characters (spaces) after/before the opening/closing tags and I am using setcookie() properly I assume.. setcookie("jf1ljj55k3q", "x", time()); Quote Link to comment https://forums.phpfreaks.com/topic/242867-cookie-error/#findComment-1247464 Share on other sites More sharing options...
premiso Posted July 26, 2011 Share Posted July 26, 2011 http://www.phpfreaks.com/forums/index.php?topic=37442.0 On a side note, your setcookie won't ever get set. You set it to expire while it is created. setcookie("jf1ljj55k3q", "x", time()+3600); Will have it expire 1 hour from now. Quote Link to comment https://forums.phpfreaks.com/topic/242867-cookie-error/#findComment-1247466 Share on other sites More sharing options...
manix Posted July 26, 2011 Author Share Posted July 26, 2011 I am guessing the problem is with my included file which echoes things, which I need, isn't there a way I can have my included file echoing and setting the cookie in the main file both at the same time ? Quote Link to comment https://forums.phpfreaks.com/topic/242867-cookie-error/#findComment-1247467 Share on other sites More sharing options...
AyKay47 Posted July 26, 2011 Share Posted July 26, 2011 if you use an output buffer you can grab the output of the include file and display it after the setcookie() call, but i normally don't recommend this Quote Link to comment https://forums.phpfreaks.com/topic/242867-cookie-error/#findComment-1247469 Share on other sites More sharing options...
manix Posted July 26, 2011 Author Share Posted July 26, 2011 Well I just copied the included file's code and pasted it in the main file so just I don't have an included file and it still gives me the error ... ? And if you don't recommend using output buffer how can I make this work otherwise? Quote Link to comment https://forums.phpfreaks.com/topic/242867-cookie-error/#findComment-1247470 Share on other sites More sharing options...
AyKay47 Posted July 26, 2011 Share Posted July 26, 2011 will make is much easier if you would post your code please Quote Link to comment https://forums.phpfreaks.com/topic/242867-cookie-error/#findComment-1247471 Share on other sites More sharing options...
manix Posted July 26, 2011 Author Share Posted July 26, 2011 Yeah right, it's 400 lines, but I've come to a solution I suppose. I copied the code from the included file in the main one and issued the cookie function before the first echo. Now this seems to work, is it correct? Quote Link to comment https://forums.phpfreaks.com/topic/242867-cookie-error/#findComment-1247474 Share on other sites More sharing options...
AyKay47 Posted July 26, 2011 Share Posted July 26, 2011 if there's no errors and your happy with the result, yes Quote Link to comment https://forums.phpfreaks.com/topic/242867-cookie-error/#findComment-1247490 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.