start() public method

Starts the Session.
public start ( ) : boolean
return boolean True if session was started
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->View = new View();
     $this->Session = new SessionHelper($this->View);
     Session::start();
     if (!Session::started()) {
         Session::start();
     }
     $_SESSION = array('test' => 'info', 'Message' => array('flash' => array('element' => 'default', 'params' => array(), 'message' => 'This is a calling'), 'notification' => array('element' => 'session_helper', 'params' => array('title' => 'Notice!', 'name' => 'Alert!'), 'message' => 'This is a test of the emergency broadcasting system'), 'classy' => array('element' => 'default', 'params' => array('class' => 'positive'), 'message' => 'Recorded'), 'bare' => array('element' => null, 'message' => 'Bare message', 'params' => array())), 'Deeply' => array('nested' => array('key' => 'value')));
 }
 /**
  * Get/Set the session id.
  *
  * When fetching the session id, the session will be started
  * if it has not already been started. When setting the session id,
  * the session will not be started.
  *
  * @param string $id Id to use (optional)
  * @return string The current session id.
  */
 public function id($id = null)
 {
     if (empty($id)) {
         Session::start();
     }
     return Session::id($id);
 }
Example #3
0
 /**
  * testSetLanguageWithSession method
  *
  * @return void
  */
 public function testSetLanguageWithSession()
 {
     Session::start();
     Session::write('Config.language', 'po');
     $singular = $this->_singular();
     $this->assertEquals('Po (translated)', $singular);
     $plurals = $this->_plural();
     $this->assertTrue(in_array('0 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('1 is 1 (po translated)', $plurals));
     $this->assertTrue(in_array('2 is 2-4 (po translated)', $plurals));
     $this->assertTrue(in_array('3 is 2-4 (po translated)', $plurals));
     $this->assertTrue(in_array('4 is 2-4 (po translated)', $plurals));
     $this->assertTrue(in_array('5 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('6 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('7 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('8 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('9 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('10 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('11 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('12 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('13 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('14 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('15 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('16 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('17 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('18 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('19 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('20 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('21 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('22 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('23 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('24 everything else (po translated)', $plurals));
     $this->assertTrue(in_array('25 everything else (po translated)', $plurals));
     Session::delete('Config.language');
 }
Example #4
0
 /**
  * testDestroy method
  *
  * @return void
  */
 public function testDestroy()
 {
     $session = new Session();
     $session->start();
     $session->write('bulletProof', 'invincible');
     $session->id('foo');
     $session->destroy();
     $this->assertFalse($session->check('bulletProof'));
 }
 /**
  * testSessionId method
  *
  * @return void
  */
 public function testSessionId()
 {
     unset($_SESSION);
     $Session = new SessionComponent($this->ComponentRegistry);
     Session::start();
     $this->assertEquals(session_id(), $Session->id());
 }