Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation] Custom session save handlers are ignored #9351

@myurasov

Description

@myurasov

The following code saved sessions to MongoDB in Symfony 2.2, but now (looks like starting with version 2.3) doesn't work - sessions are stored in filesystem.

In other words - if I downgrade to Symfony HttpFoundation 2.2 - everything works, when I go to 2.3 - it breaks.

use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler;

// ...

$sessionHandler = new MongoDbSessionHandler(
  new \MongoClient("mongodb://localhost:27017"), [
    "database" => "MyDatabase",
    "collection" => "sessions"
  ]
);

session_set_save_handler(
  array($sessionHandler, "open"),
  array($sessionHandler, "close"),
  array($sessionHandler, "read"),
  array($sessionHandler, "write"),
  array($sessionHandler, "destroy"),
  array($sessionHandler, "gc")
);

// ...

$session = new Session();
$session->set('something', 'abc');

Note that session is NOT started by legacy php code elsewhere.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions