id() публичный метод

Calling this method will not auto start the session. You might have to manually assert a started session. Passing an id into it, you can also replace the session id if the session has not already been started. Note that depending on the session handler, not all characters are allowed within the session id. For example, the file session handler only allows characters in the range a-z A-Z 0-9 , (comma) and - (minus).
public id ( string | null $id = null ) : string
$id string | null Id to replace the current session id
Результат string Session id
Пример #1
0
 /**
  * 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 ($id === null) {
         $session = $this->_session;
         $session->start();
         return $session->id();
     }
     $this->_session->id($id);
 }
Пример #2
0
 /**
  * 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);
 }
Пример #3
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'));
 }
Пример #4
-1
 /**
  * testStatelessAuthNoSessionStart method
  *
  * @return void
  */
 public function testStatelessAuthNoSessionStart()
 {
     if (Session::id()) {
         session_destroy();
         Session::$id = null;
     }
     $event = new Event('Controller.startup', $this->Controller);
     AuthComponent::$sessionKey = false;
     $this->Auth->config('authenticate', ['Basic' => array('userModel' => 'AuthUsers')]);
     $this->Controller->request['action'] = 'admin_add';
     $this->Controller->request->env('PHP_AUTH_USER', 'mariano');
     $this->Controller->request->env('PHP_AUTH_PW', 'cake');
     $result = $this->Auth->startup($event);
     $this->assertNull($result);
     $this->assertNull(Session::id());
 }