Esempio n. 1
0
 public function testSessionFilesWrite()
 {
     $session_path = __DIR__ . '/cache';
     ini_set('session.save_handler', 'files');
     ini_set('session.save_path', $session_path);
     ini_set('session.serialize_handler', 'php');
     // Write
     $session = new Phalcon\Session\Adapter\Files();
     $session->start();
     @session_start();
     // https://github.com/phalcon/cphalcon/issues/11129
     if (version_compare(phpversion(), "5.4.0", "<")) {
         $this->assertEquals($session::SESSION_NONE, $session->status());
     } else {
         $this->assertEquals($session::SESSION_ACTIVE, $session->status());
     }
     $session->set('some', 'write-value');
     $this->assertEquals($session->get('some'), 'write-value');
     $this->assertTrue($session->has('some'));
     $session_id = $session->getId();
     $this->assertNotEmpty($session_id);
     session_write_close();
     unset($session);
     // Check session file
     $session_file = $session_path . '/sess_' . $session_id;
     $this->assertTrue(is_file($session_file));
     $this->assertNotEmpty(@file_get_contents($session_file));
     // Read
     $session = new Phalcon\Session\Adapter\Files();
     $session->start();
     @session_start();
     $session->setId($session_id);
     $this->assertTrue($session->has('some'));
     $this->assertEquals($session->get('some'), 'write-value');
     $session->remove('some');
     $this->assertFalse($session->has('some'));
     @session_write_close();
     unset($session);
     // Check session file
     $this->assertTrue(is_file($session_file));
     $this->assertEmpty(@file_get_contents($session_file));
     @unlink($session_file);
 }
Esempio n. 2
0
 public function testSessionFilesWrite()
 {
     $session_path = __DIR__ . '/cache';
     ini_set('session.save_handler', 'files');
     ini_set('session.save_path', $session_path);
     ini_set('session.serialize_handler', 'php');
     // Write
     $session = new Phalcon\Session\Adapter\Files();
     $session->start();
     @session_start();
     $session->set('some', 'write-value');
     $this->assertEquals($session->get('some'), 'write-value');
     $this->assertTrue($session->has('some'));
     $session_id = $session->getId();
     $this->assertNotEmpty($session_id);
     session_write_close();
     unset($session);
     // Check session file
     $session_file = $session_path . '/sess_' . $session_id;
     $this->assertTrue(is_file($session_file));
     $this->assertNotEmpty(@file_get_contents($session_file));
     // Read
     $session = new Phalcon\Session\Adapter\Files();
     $session->start();
     @session_start();
     $session->setId($session_id);
     $this->assertTrue($session->has('some'));
     $this->assertEquals($session->get('some'), 'write-value');
     $session->remove('some');
     $this->assertFalse($session->has('some'));
     @session_write_close();
     unset($session);
     // Check session file
     $this->assertTrue(is_file($session_file));
     $this->assertEmpty(@file_get_contents($session_file));
     @unlink($session_file);
 }