Cake\Network\Session::start PHP Method

start() public method

Starts the Session.
public start ( ) : boolean
return boolean True if session was started
    public function start()
    {
        if ($this->_started) {
            return true;
        }
        if ($this->_isCLI) {
            $_SESSION = [];
            return $this->_started = true;
        }
        if (session_status() === \PHP_SESSION_ACTIVE) {
            throw new RuntimeException('Session was already started');
        }
        if (ini_get('session.use_cookies') && headers_sent($file, $line)) {
            return;
        }
        if (!session_start()) {
            throw new RuntimeException('Could not start the session');
        }
        $this->_started = true;
        if ($this->_timedOut()) {
            $this->destroy();
            return $this->start();
        }
        return $this->_started;
    }

Usage Example

 /**
  * 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')));
 }
All Usage Examples Of Cake\Network\Session::start