如何在不更改原始源代码的情况下解决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();
// ...
答案 0 :(得分:5)
FB sdk启动会话only if it's not started already。在启动silex会话的代码之后移动sdk初始化。
This是Symfony2用来查看用户是否有会话的函数。实质上,它会检查会话cookie的存在。