public function testSessionFiles() { $session = new Phalcon\Session\Adapter\Files(); $this->assertFalse($session->start()); $this->assertFalse($session->isStarted()); @session_start(); $session->set('some', 'value'); $this->assertEquals($session->get('some'), 'value'); $this->assertTrue($session->has('some')); $this->assertEquals($session->get('undefined', 'my-default'), 'my-default'); }
public function testSessionFiles() { $session = new Phalcon\Session\Adapter\Files(); $this->assertFalse($session->start()); $this->assertFalse($session->isStarted()); @session_start(); $session->set('some', 'value'); $this->assertEquals($session->get('some'), 'value'); $this->assertTrue($session->has('some')); $this->assertEquals($session->get('undefined', 'my-default'), 'my-default'); // Automatically deleted after reading $this->assertEquals($session->get('some', NULL, TRUE), 'value'); $this->assertFalse($session->has('some')); @session_destroy(); }
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); }
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); }
<?php /*<!--Check auth-->*/ $session = new \Phalcon\Session\Adapter\Files(); $session->start(); $auth = $session->get('auth'); if (!$auth) { return false; } elseif ($auth->admin_session !== true) { return false; } /*<!--/Check auth-->*/ error_reporting(0); // Set E_ALL for debuging include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'elFinderConnector.class.php'; include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'elFinder.class.php'; include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'elFinderVolumeDriver.class.php'; include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'elFinderVolumeLocalFileSystem.class.php'; // Required for MySQL storage connector // include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeMySQL.class.php'; // Required for FTP connector support // include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeFTP.class.php'; /** * # Dropbox volume driver need "dropbox-php's Dropbox" and "PHP OAuth extension" or "PEAR's HTTP_OAUTH package" * * dropbox-php: http://www.dropbox-php.com/ * * PHP OAuth extension: http://pecl.php.net/package/oauth * * PEAR's HTTP_OAUTH package: http://pear.php.net/package/http_oauth * * HTTP_OAUTH package require HTTP_Request2 and Net_URL2 */ // Required for Dropbox.com connector support // include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDropbox.class.php';
<?php $session = new Phalcon\Session\Adapter\Files(array('uniqueId' => 'my-private-app')); $session->start(); $session->set('var', 'some-value'); echo $session->get('var');