-1

Possible Duplicate:
Headers already sent by PHP

I don't know, what to do with this error message.

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /data/web/virtuals/8301/virtual/www/subdom/fb/soutez/fbmain.php:1) in /data/web/virtuals/8301/virtual/www/subdom/fb/soutez/facebook.php on line 37

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /data/web/virtuals/8301/virtual/www/subdom/fb/soutez/fbmain.php:1) in /data/web/virtuals/8301/virtual/www/subdom/fb/soutez/facebook.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at /data/web/virtuals/8301/virtual/www/subdom/fb/soutez/fbmain.php:1) in /data/web/virtuals/8301/virtual/www/subdom/fb/soutez/base_facebook.php on line 589

What is wrong? My facebook app didn't work in IE, so I tried to add P3P header. Since this time, my life has been hell. And I also don't get, what was wrong with my app. It contained only small form and when I tried to submit this form, IE redirected me back to the form instead of submit.php

Community
  • 1
  • 1
Kolemjdouci
  • 1
  • 1
  • 1
  • Perhaps posting the relevant part of your code might be useful. Re What is wrong: you can only add `header()`s *before* you send any content - check for spaces (or the Unicode BOM) at the beginning of your PHP file, **and** any files you have included. – Piskvor left the building Aug 03 '11 at 10:26
  • Why do you need a P3P header to fix some error? Everything should work even in IE without such headers. Try to find the real/initial error, rather then fixing around. – feeela Aug 03 '11 at 10:29
  • I wrote, why I added P3P header. Because my app contained only small form and when I tried to submit this form, IE redirected me back to the form instead of submit.php....I found, that it could be solved by adding the P3P. – Kolemjdouci Aug 03 '11 at 11:45

3 Answers3

1

You need to send all headers before any output is actually sent to the client. There are two solutions.

  1. Put the header() call on top of your document (or before any calls to echo and/or/ print).
  2. Use output buffering and output all buffered content at the end of your document.
supakeen
  • 2,876
  • 19
  • 19
1

It seems that you are using the PHP-SDK, where the Facebook class inside facebook.php uses session_start();.

So you are creating an instance of the class before setting the P3P header, maybe something like this:

$facebook = new Facebook(array(
  'appId' => 'app_id',
  'secret' => 'app_secret',
));
...
some code here
...
header('P3P: CP=HONK');

What you need to do is just send the header before initializing the Facebook class:

header('P3P: CP=HONK');
$facebook = new Facebook(array(
  'appId' => 'app_id',
  'secret' => 'app_secret',
));
ifaour
  • 38,035
  • 12
  • 72
  • 79
  • Everything is the same. I tried to put the header to the same file as the initializing tha Facebook class. But it's worse. Now, I click on the application tab, it throws me some session errors and then redirects me on my signup form. Really nice. – Kolemjdouci Aug 03 '11 at 12:04
  • make sure you dont have a "white space" at the beginning of your file or other files you have included. for example a space before the ` – ifaour Aug 03 '11 at 14:06
0

You can place

<?php ob_start(); ?>

at the beginning of your script.

Patrik
  • 2,695
  • 1
  • 21
  • 36
  • I overlooked all these solutions with whitespaces, but NetBeans saved my day, thanks. Redirection back to my form after submitting is still here. – Kolemjdouci Aug 03 '11 at 22:32