user3044450
user3044450

Reputation: 7

Cannot send session cookie - headers already sent by error in my wordpress site

I'm facing this errors on my wordpress site.

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /x/x/x/x/x/imdbimporter/imdbimporter.php:1) in /x/x/x/x/x/imdbimporter/main.php on line 24

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /x/x/x/x/x/imdbimporter/imdbimporter.php:1) in /x/x/x/x/x/imdbimporter/main.php on line 24

imdbimporter.php

<?php

/*
Plugin Name: IMDB Importer
Plugin URI: http://goo.gl/Kotx0
Description: IMDB Importer is a wordpress plugin that helps you post videos from imdb.com.
Author: Intensecool
Version: 5.0
Author URI: http://www.wpimdbautomator.com
*/

$dir = (defined(__DIR__)) ?  __DIR__ : dirname(__FILE__);

include($dir.'/main.php');

?>

Main.php contents

<?php

if (is_admin()) {

    require_once $dir."/curl.class.php";
    $cURL = new cURL(false);

    $home_url = get_option('home');

    if (get_option('imdb_license_register') != $home_url) {
        $post_data = "hostname=".$home_url;
        $result = $cURL->post("http://wp.infocloud.lt/insert_domain.php", $post_data, false);
        //echo $result;
        update_option('imdb_license_register', $home_url);
    }

    $post_data = "hostname=".$home_url;
    $result = $cURL->post("http://wp.infocloud.lt/get_domain.php", $post_data, false);

    if ($result == $home_url) {
        echo "Hi.";
    }
    else {
        session_start();
        include($dir.'/admin.php');
    }

}

I am using a plugin named IMDB Importer on my site and the plugin code is giving the error. I know it's a problem with session start but I was not able to fix it. Please help me with it. I hope to get it fixed it soon. Thanks!

Upvotes: 0

Views: 4292

Answers (2)

newman
newman

Reputation: 2719

Check what in imdbimporter.php not exists any spaces or others symbols before <?php Any text editors can insert in begin of file special symbols for detect UTF-8 charset

Upvotes: 2

zzlalani
zzlalani

Reputation: 24384

try this

else {
    if (session_id() == "") {
       session_start();
    }
    include($dir.'/admin.php');
}

Upvotes: 0

Related Questions