Adam Elsodaney
Adam Elsodaney

Reputation: 7808

Symfony/Silex + Facebook SDK : Session Start conflict

How do I resolve session_start conflicts without changing the original source code? And how does the Symfony component or Silex check to see if a session already exists?

Notice: A session had already been started - ignoring session_start() in
myapp/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php on line 146

EDIT: here's the first few lines of index.php

require_once __DIR__.'/vendor/autoload.php';

/**
 * from Heroku's Facebook template
 */
require_once('AppInfo.php');
require_once('utils.php');


use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Yaml\Parser;
use Silex\Provider\FormServiceProvider;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Currently using git submodule, will move to composer.json
 */
require_once('sdk/src/facebook.php');

$facebook = new Facebook(array(
  'appId'  => AppInfo::appID(),
  'secret' => AppInfo::appSecret(),
));

$app = new Silex\Application();
// ...

Upvotes: 2

Views: 1604

Answers (1)

Maerlyn
Maerlyn

Reputation: 34107

The FB sdk starts the session only if it's not started already. Move the sdk initialization after the code that starts silex's session.

This is the function Symfony2 uses to see if the user has a session. In essence it checks the existence of a session cookie.

Upvotes: 5

Related Questions