jdock1 Posted September 14, 2011 Share Posted September 14, 2011 I just did a huge import from an app I have been working on. No issues except for this. I uploaded & imported all files & databases from my wampserver (localhost, local server) to my main online server. Before I continue with the problem, I have to give you info on how the files work. I am using a "controller" to view the files. Meaning, from index.php, I call all the files. For example, instead of mysite.com/register.php, its mysite.com/index.php?page=register. The index defines the doctype & html tags etc. The other files that are called through index.php are just pure php code, it does not contain the head & body tags etc. So, the issue is , when the surfer submits a form, i need to set a cookie. this cookie is VERY important. I cannot get it to work. I am getting the header warnings after submit Of course, this is to be expected. But I tried it on my local server, & it worked. I am not very familiar with cookies, this is a side of PHP i never really even touched. I know almost everything but that. So the php code is before the html code on the page, so I figured it was worth a shot. Im guessing the problem here is, since the code being outputted as index.php code + the form page code. So the cookie is being set after the html tags. How can I fix this? I need it to work thru the controller. I cannot just make it a single file, all files on the site needs to be thru this controller, otherwise it will mess everything up. Ino I could just add the code from index.php plus the form page code & just run the php code before all of the html tags, but like I said it has to be called thru index.php. I appreciate your replies, & I hope you guys dont think im an idiot & can understand my question, im terrible with words! Quote Link to comment https://forums.phpfreaks.com/topic/247097-setcookie-issue-working-on-local-server-not-working-on-real-server/ Share on other sites More sharing options...
Pikachu2000 Posted September 14, 2011 Share Posted September 14, 2011 If you're getting a 'headers already sent' warning, then you're obviously attempting to set the cookie after some sort of output has already been sent to the browser. http://www.phpfreaks.com/forums/index.php?topic=37442.0 Quote Link to comment https://forums.phpfreaks.com/topic/247097-setcookie-issue-working-on-local-server-not-working-on-real-server/#findComment-1269063 Share on other sites More sharing options...
voip03 Posted September 14, 2011 Share Posted September 14, 2011 To avoid the header error, you can use this code. <? php /* "Warning: Cannot modify header information - headers already sent by " To avoid the header error , give value zero to $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; */ $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; ob_start(); Quote Link to comment https://forums.phpfreaks.com/topic/247097-setcookie-issue-working-on-local-server-not-working-on-real-server/#findComment-1269072 Share on other sites More sharing options...
jdock1 Posted September 15, 2011 Author Share Posted September 15, 2011 To avoid the header error, you can use this code. <? php /* "Warning: Cannot modify header information - headers already sent by " To avoid the header error , give value zero to $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; */ $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; ob_start(); So will that actually set the cookie though? Quote Link to comment https://forums.phpfreaks.com/topic/247097-setcookie-issue-working-on-local-server-not-working-on-real-server/#findComment-1269649 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.