当前位置: 首页>>代码示例>>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;未经允许,请勿转载。