Karim Mtl
Karim Mtl

Reputation: 1251

Sentinel session error when used with Silex/Symfony

My Silex app uses Sentinel for authentication. How can I fix this error?

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 comes with a Session class from symfony. I would guess Sentinel uses the php session directly $_SESSION. How can I make them both coexist? Or is there a way to use custom session classes with Sentinel?

Upvotes: -1

Views: 315

Answers (1)

Karim Mtl
Karim Mtl

Reputation: 1251

Problem solved. To make Symfony Session coexist with native PHP session we must use php bridge as storage. Here is how I solved the problem in Silex:

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

Hope that helps other people.

Upvotes: 0

Related Questions