2

如何在不更改原始源代码的情况下解决 session_start 冲突?Symfony 组件或 Silex 如何检查会话是否已经存在?

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

编辑:这是 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();
// ...
4

1 回答 1

5

FB sdk仅在尚未启动时才启动会话。将 sdk 初始化移到启动 silex 会话的代码之后。

是 Symfony2 用来查看用户是否有会话的函数。本质上,它检查会话 cookie 的存在。

于 2012-07-03T10:58:54.593 回答