Пример #1
0
 public function storeSession(Session $session)
 {
     $context = new Context();
     if (!$context->IsCliInvocation) {
         session_start();
     }
     $namespace = $session->getNamespace();
     $_SESSION[$namespace] = $session->exportRawData();
     // 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();
     }
 }
Пример #2
0
 public function testSessionGetsProvider()
 {
     Session::setDefaultSessionProviderClassName("Rhubarb\\Crown\\Tests\\Sessions\\UnitTestingSessionProvider");
     $session = new UnitTestingSession();
     $this->assertInstanceOf("Rhubarb\\Crown\\Tests\\Sessions\\UnitTestingSessionProvider", $session->testGetSessionProvider());
     Session::setDefaultSessionProviderClassName("Rhubarb\\Crown\\Sessions\\SessionProviders\\PhpSessionProvider");
     // Although we have changed the default provider, we already instantiated the session so the provider will not
     // have changed
     $this->assertInstanceOf("Rhubarb\\Crown\\Tests\\Sessions\\UnitTestingSessionProvider", $session->testGetSessionProvider());
 }
Пример #3
0
 public function extractSessionData()
 {
     $data = parent::extractSessionData();
     $encrypted = [];
     $keySalt = $this->getEncryptionKeySalt();
     $provider = Container::instance(EncryptionProvider::class);
     foreach ($data as $key => $value) {
         if (is_object($value) || is_array($value)) {
             continue;
         }
         $encrypted[$key] = $provider->encrypt($value, $keySalt);
     }
     return $encrypted;
 }
Пример #4
0
 public function __get($propertyName)
 {
     $keySalt = $this->getEncryptionKeySalt();
     $provider = EncryptionProvider::getEncryptionProvider();
     return $provider->decrypt(parent::__get($propertyName), $keySalt);
 }