与 Silex/Symfony 一起使用时哨兵会话错误

Sentinel session error when used with Silex/Symfony

我的 Silex 应用程序使用 Sentinel 进行身份验证。我该如何解决这个错误?

PHP Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /home/me/workspace/codeexample/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php on line 56

Silex 带有来自 symfony 的会话 class。我猜 Sentinel 直接使用 php 会话 $_SESSION。我怎样才能让它们共存?或者有没有办法将自定义会话 classes 与 Sentinel 一起使用?

问题已解决。要使 Symfony Session 与原生 PHP session 共存,我们必须使用 php bridge 作为存储。以下是我在 Silex 中解决问题的方法:

$app->register(new \Silex\Provider\SessionServiceProvider(), [
    'session.storage' => new \Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage
]);

希望对其他人有所帮助。