/**
  * Proves that invalid sessions will be destroyed and re-created
  * if invalid
  *
  * @return void
  */
 public function testInvalidSessionRenew()
 {
     TestCakeSession::start();
     $this->assertNotEmpty($_SESSION['Config']);
     $data = $_SESSION;
     session_write_close();
     $_SESSION = null;
     TestCakeSession::start();
     $this->assertEquals($data, $_SESSION);
     TestCakeSession::write('Foo', 'Bar');
     session_write_close();
     $_SESSION = null;
     TestCakeSession::userAgent('bogus!');
     TestCakeSession::start();
     $this->assertNotEquals($data, $_SESSION);
     $this->assertEquals('bogus!', $_SESSION['Config']['userAgent']);
 }
Example #2
0
 /**
  * testSessionTimeout method
  *
  * @return void
  */
 public function testSessionTimeout()
 {
     Configure::write('debug', 2);
     Configure::write('Session.autoRegenerate', false);
     $timeoutSeconds = Configure::read('Session.timeout') * 60;
     TestCakeSession::destroy();
     TestCakeSession::write('Test', 'some value');
     $this->assertEquals(time() + $timeoutSeconds, CakeSession::$sessionTime);
     $this->assertEquals(10, $_SESSION['Config']['countdown']);
     $this->assertEquals(CakeSession::$sessionTime, $_SESSION['Config']['time']);
     $this->assertEquals(time(), CakeSession::$time);
     $this->assertEquals(time() + $timeoutSeconds, $_SESSION['Config']['time']);
     Configure::write('Session.harden', true);
     TestCakeSession::destroy();
     TestCakeSession::write('Test', 'some value');
     $this->assertEquals(time() + $timeoutSeconds, CakeSession::$sessionTime);
     $this->assertEquals(10, $_SESSION['Config']['countdown']);
     $this->assertEquals(CakeSession::$sessionTime, $_SESSION['Config']['time']);
     $this->assertEquals(time(), CakeSession::$time);
     $this->assertEquals(CakeSession::$time + $timeoutSeconds, $_SESSION['Config']['time']);
 }
Example #3
0
/**
 * Test that cookieTimeout matches timeout when unspecified.
 *
 * @return void
 */
	public function testCookieTimeoutFallback() {
		$_SESSION = null;
		Configure::write('Session', array(
			'defaults' => 'cake',
			'timeout' => 400,
		));
		TestCakeSession::start();
		$this->assertEquals(400, Configure::read('Session.cookieTimeout'));
		$this->assertEquals(400, Configure::read('Session.timeout'));
		$this->assertEquals(400 * 60, ini_get('session.cookie_lifetime'));
		$this->assertEquals(400 * 60, ini_get('session.gc_maxlifetime'));

		$_SESSION = null;
		Configure::write('Session', array(
			'defaults' => 'cake',
			'timeout' => 400,
			'cookieTimeout' => 600
		));
		TestCakeSession::start();
		$this->assertEquals(600, Configure::read('Session.cookieTimeout'));
		$this->assertEquals(400, Configure::read('Session.timeout'));
	}
 /**
  * Test that cookieTimeout matches timeout when unspecified.
  *
  * @return void
  */
 public function testCookieTimeoutFallback()
 {
     $_SESSION = null;
     Configure::write('Session', array('defaults' => 'php', 'timeout' => 400));
     TestCakeSession::start();
     $this->assertEquals(400, Configure::read('Session.cookieTimeout'));
     $this->assertEquals(400, Configure::read('Session.timeout'));
     $_SESSION = null;
     Configure::write('Session', array('defaults' => 'php', 'timeout' => 400, 'cookieTimeout' => 600));
     TestCakeSession::start();
     $this->assertEquals(600, Configure::read('Session.cookieTimeout'));
     $this->assertEquals(400, Configure::read('Session.timeout'));
 }