當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Session::create方法代碼示例

本文整理匯總了PHP中Cake\Network\Session::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::create方法的具體用法?PHP Session::create怎麽用?PHP Session::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Cake\Network\Session的用法示例。


在下文中一共展示了Session::create方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fromGlobals

 /**
  * {@inheritDoc}
  */
 public static function fromGlobals(array $server = null, array $query = null, array $body = null, array $cookies = null, array $files = null)
 {
     $request = parent::fromGlobals($server, $query, $body, $cookies, $files);
     list($base, $webroot) = static::getBase($request);
     $sessionConfig = (array) Configure::read('Session') + ['defaults' => 'php', 'cookiePath' => $webroot];
     $session = Session::create($sessionConfig);
     $request = $request->withAttribute('base', $base)->withAttribute('webroot', $webroot)->withAttribute('session', $session);
     if ($base) {
         $request = static::updatePath($base, $request);
     }
     return $request;
 }
開發者ID:nrother,項目名稱:cakephp,代碼行數:15,代碼來源:ServerRequestFactory.php

示例2: getSession

 /**
  * Get instance of the session.
  *
  * @return \Cake\Network\Session
  */
 public function getSession()
 {
     if (!empty($this->cake['session'])) {
         return $this->cake['session'];
     }
     if (!empty($this->cake['request'])) {
         $this->cake['session'] = $this->cake['request']->session();
         return $this->cake['session'];
     }
     $config = (array) Configure::read('Session') + ['defaults' => 'php'];
     $this->cake['session'] = Session::create($config);
     return $this->cake['session'];
 }
開發者ID:cakephp,項目名稱:codeception,代碼行數:18,代碼來源:Connector.php

示例3: createFromGlobals

 /**
  * Wrapper method to create a new request from PHP superglobals.
  *
  * Uses the $_GET, $_POST, $_FILES, $_COOKIE, $_SERVER, $_ENV and php://input data to construct
  * the request.
  *
  * @return \Cake\Network\Request
  */
 public static function createFromGlobals()
 {
     list($base, $webroot) = static::_base();
     $sessionConfig = (array) Configure::read('Session') + ['defaults' => 'php', 'cookiePath' => $webroot];
     $config = ['query' => $_GET, 'post' => $_POST, 'files' => $_FILES, 'cookies' => $_COOKIE, 'environment' => $_SERVER + $_ENV, 'base' => $base, 'webroot' => $webroot, 'session' => Session::create($sessionConfig)];
     $config['url'] = static::_url($config);
     return new static($config);
 }
開發者ID:alexunique0519,項目名稱:Blog_Cakephp_association,代碼行數:16,代碼來源:Request.php

示例4: _buildRequest

 /**
  * Creates a request object with the configured options and parameters.
  *
  * @param string|array $url The URL
  * @param string $method The HTTP method
  * @param array|null $data The request data.
  * @return \Cake\Network\Request The built request.
  */
 protected function _buildRequest($url, $method, $data)
 {
     $sessionConfig = (array) Configure::read('Session') + ['defaults' => 'php'];
     $session = Session::create($sessionConfig);
     $session->write($this->_session);
     list($url, $query) = $this->_url($url);
     $props = ['url' => $url, 'post' => $data, 'cookies' => $this->_cookie, 'session' => $session, 'query' => $query];
     $env = [];
     if (isset($this->_request['headers'])) {
         foreach ($this->_request['headers'] as $k => $v) {
             $env['HTTP_' . str_replace('-', '_', strtoupper($k))] = $v;
         }
         unset($this->_request['headers']);
     }
     $env['REQUEST_METHOD'] = $method;
     $props['environment'] = $env;
     $props = Hash::merge($props, $this->_request);
     return new Request($props);
 }
開發者ID:hossain-seaos,項目名稱:cakephp,代碼行數:27,代碼來源:IntegrationTestCase.php

示例5: _buildRequest

 /**
  * Creates a request object with the configured options and parameters.
  *
  * @param string|array $url The URL
  * @param string $method The HTTP method
  * @param array|null $data The request data.
  * @return array The request context
  */
 protected function _buildRequest($url, $method, $data)
 {
     $sessionConfig = (array) Configure::read('Session') + ['defaults' => 'php'];
     $session = Session::create($sessionConfig);
     $session->write($this->_session);
     list($url, $query) = $this->_url($url);
     $tokenUrl = $url;
     if ($query) {
         $tokenUrl .= '?' . http_build_query($query);
     }
     $props = ['url' => $url, 'post' => $this->_addTokens($tokenUrl, $data), 'cookies' => $this->_cookie, 'session' => $session, 'query' => $query];
     if (is_string($data)) {
         $props['input'] = $data;
     }
     $env = [];
     if (isset($this->_request['headers'])) {
         foreach ($this->_request['headers'] as $k => $v) {
             $name = strtoupper(str_replace('-', '_', $k));
             if (!in_array($name, ['CONTENT_LENGTH', 'CONTENT_TYPE'])) {
                 $name = 'HTTP_' . $name;
             }
             $env[$name] = $v;
         }
         unset($this->_request['headers']);
     }
     $env['REQUEST_METHOD'] = $method;
     $props['environment'] = $env;
     $props = Hash::merge($props, $this->_request);
     return $props;
 }
開發者ID:aceat64,項目名稱:cakephp,代碼行數:38,代碼來源:IntegrationTestCase.php

示例6: testUsingPluginHandler

 /**
  * test using a handler from a plugin.
  *
  * @return void
  */
 public function testUsingPluginHandler()
 {
     Configure::write('App.namespace', 'TestApp');
     \Cake\Core\Plugin::load('TestPlugin');
     $config = ['defaults' => 'cake', 'handler' => ['engine' => 'TestPlugin.TestPluginSession']];
     $session = Session::create($config);
     $this->assertInstanceOf('TestPlugin\\Network\\Session\\TestPluginSession', $session->engine());
     $this->assertEquals('user', ini_get('session.save_handler'));
 }
開發者ID:Slayug,項目名稱:castor,代碼行數:14,代碼來源:SessionTest.php

示例7: _getUserId

 /**
  * Gets current User's ID.
  *
  * @return int User ID, zero if not found
  */
 protected function _getUserId()
 {
     $callable = $this->config('idCallable');
     $id = 0;
     if (is_string($callable)) {
         $session = Session::create();
         $id = $session->read($callable);
     } elseif (is_callable($callable)) {
         $id = $callable();
     }
     return (int) $id;
 }
開發者ID:quickapps-plugins,項目名稱:user,代碼行數:17,代碼來源:WhoDidItBehavior.php


注:本文中的Cake\Network\Session::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。