I have problem with a session in Symfony 2.1 for a site inside Symfony (in one controller).
I set the session like this:
$this->get("session")
->set('UserMongoId', $this->get('security.context')->getToken()->getUser()->getId());
After that in another file (inside the web folder of Symfony) outside symfony 2.1, I do
this:
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('rpod', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$session = new \Symfony\Component\HttpFoundation\Session\Session();
$session->start();
var_dump ($session);
$user_id = $session->get("UserMongoId");
However I received null, and I dont know how to make it work, any ideas?
now I trying MongoDbSessionHandler and storage the session in db with mongo
I get it store the session in db with mongo:
1.- service.yml
2.- confing.yml add :
3.- after that doctrinemongo db with MongoDbSessionHandler will save all the session automatically in db perfect if we are going to work with direferents servers. will be something like that:
4.- In one file outside symfony 2.1 ( i have the file now in web for not load the components )
and the variable data has all the session for this user.
5.- Now, the next step is send to this last file the access_token_secret and check it in the result of $data = $mongoSession->read($_COOKIE[“PHPSESSID”]);
works for me, I’m waiting for your comments