Jump to content

setcookie issue, working on local server, not working on real server


jdock1

Recommended Posts

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!

Link to comment
Share on other sites

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();

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.