[text]Warning: Cannot modify header information - headers already sent by (output started at /home/j562595/public_html/site/a_sitelogin.php:16) in /home/j56259544/public_html/site/a_sitelogin.php on line 17
Warning: Cannot modify header information - headers already sent by (output started at /home/j562595/public_html/site/a_sitelogin.php:16) in /home/j56259544/public_html/site/a_sitelogin.php on line 18
Warning: Cannot modify header information - headers already sent by (output started at /home/j562595/public_html/sites/a_sitelogin.php:16) in /home/j56259544/public_html/site/a_sitelogin.php on line 19
Warning: Cannot modify header information - headers already sent by (output started at /home/j562595/public_html/site/a_sitelogin.php:16) in /home/j56259544/public_html/site/a_sitelogin.php on line 20
Warning: Cannot modify header information - headers already sent by (output started at /home/j562595/public_html/site/a_sitelogin.php:16) in /home/j56259544/public_html/site/a_sitelogin.php on line 21[/text]
We are now hosting about 5 sites on a new service. All are ok. We can login to them all fine - except this one.
The cost is the same, except this uses PDO.
For some reason, it won't let us set Cookies. If I echo the output of the database query, it shows the data, but just won't set the cookies.
I don't know what ..... .php:16 means either.
Why would all the sites work, but this one? The code is the same. Especially the SetCookie code.
Bizarre Headers Error when setting Cookies
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Bizarre Headers Error when setting Cookies
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Bizarre Headers Error when setting Cookies
It's complaining about something on line 16 of a_sitelogin.php. What's going on there?
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Bizarre Headers Error when setting Cookies
Code: Select all
while ($row = mysql_fetch_object($result))
{
echo "<b>$row->email</b><br/><b>$row->type</b>";
setcookie("user", $row->firstname, time()+13600);
setcookie("email", $email, time()+13600);
setcookie("userid", $row->id, time()+13600);
setcookie("type", $row->type, time()+13600);
setcookie("username", $row->username, time()+13600);It's not storing the cookies.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Bizarre Headers Error when setting Cookies
setcookie()setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Bizarre Headers Error when setting Cookies
Probably... but then ALL (and I mean ALL) our web sites that use Cookies, run correctly without a hitch, like this.
So why is this one web site doing this.
We now have three domains on this server, and they all have idential scripts.
So why is this one web site doing this.
We now have three domains on this server, and they all have idential scripts.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Bizarre Headers Error when setting Cookies
Sorted it.
I had echoed something before it, but only to test. Now I have removed it - it works. Yet it wasn't there before and didn't work! lol
I had echoed something before it, but only to test. Now I have removed it - it works. Yet it wasn't there before and didn't work! lol
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.