开发者

Facebook iframe - headers already sent [duplicate]

开发者 https://www.devze.com 2023-03-25 02:55 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Headers already sent by PHP
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Headers already sent by PHP

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

Warning: sessio开发者_JAVA技巧n_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


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.


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',
));


You can place

<?php ob_start(); ?>

at the beginning of your script.

0

精彩评论

暂无评论...
验证码 换一张
取 消