I'm working on a Symfony2 implementation of this http://php.net/manual/fr/function.session-destroy.php#114709
It's a function that destroys a session by its ID.
private function destroyGivenSessions($ssid)
{
$ssid = '1pfj5rj73knh2mdo8ks9iqng51'; // for tests
$request = $this->getRequest();
$session = $request->getSession();
$currentSession = $session->getId(); // store current session
$session->setId($ssid);
$session->start();
$session->invalidate();
$session->setId($currentSession); // restore old session
$session->start();
}
This function destroys the given session but, instead of restoring the old session stored in $currentSession
, it regenerates a new ID so I end up destroying the given session and loosing my current session.. What am I doing wrong ?