2012-07-03 86 views
2

如何在不更改原始源代碼的情況下解決session_start衝突? Symfony組件或Silex如何檢查會話是否已經存在?Symfony/Silex + Facebook SDK:會話開始衝突

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(); 
// ... 

回答

5

的FB SDK啓動會話only if it's not started already的前幾行。在啓動silex會話的代碼之後移動sdk初始化。

This是Symfony2用來查看用戶是否有會話的功能。本質上它檢查會話cookie的存在。

+0

謝謝,也爲鏈接。這看起來像你我的人去Silex相關的幫助;) –

+0

我正在關注rss中的silex標籤,並在我能的時候幫忙。 :) – Maerlyn

+0

如果您想使用Facebook身份驗證,則該解決方案不可能或者至少非常非常難看,因爲在請求遇到控制器之前安全性必須發生。 – shredding