public function restoreSession(Session $session)
 {
     $context = new Context();
     if (!$context->IsCliInvocation) {
         session_start();
     }
     $namespace = $session->getNamespace();
     if (isset($_SESSION[$namespace])) {
         $session->importRawData($_SESSION[$namespace]);
     }
     // Close the session to make sure we aren't locking other process for this user, e.g.
     // simultaneous AJAX requests.
     if (!$context->IsCliInvocation) {
         session_write_close();
     }
 }