stefun
stefun

Reputation: 1541

Failed to start the session: already started by PHP ($_SESSION is set) for facebook PHP SDK

I'm implementing facebook app in symfony. I used facebook php SDK

When I call

$me=$facebook->api("/me");

    if(isset($me['id']))
        $response=$facebook->api("/".$me['id']."/notifications",
                "POST",
                array (
                        'access_token'=>$accesstoken,
                        'href' => 'notification',
                        'template' => $message,
                ));

In Symfony action I'm getting:

Failed to start the session: already started by PHP ($_SESSION is set) 

How can I solve this issue?

Upvotes: 0

Views: 771

Answers (2)

Raaz
Raaz

Reputation: 1771

Add this line of code right after the initialization of $me var.

$session = $this->get('session');
 $session->start();

Upvotes: 1

Niraj Shah
Niraj Shah

Reputation: 15457

You add a @ sign in from of session_start() to suppress the error. This way, you can keep the line of code incase the session wasn't previously started, but the error will be hidden in case it was already started:

@session_start();

Upvotes: 0

Related Questions