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


PHP CakeSession::sessionTime方法代碼示例

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


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

示例1: _configureSession

 /**
  * Helper method to initialize a session, based on CakePHP core settings.
  *
  * Sessions can be configured with a few shortcut names as well as have any number of ini settings declared.
  *
  * @return void
  * @throws CakeSessionException Throws exceptions when ini_set() fails.
  */
 protected static function _configureSession()
 {
     $sessionConfig = Configure::read('Session');
     if (isset($sessionConfig['defaults'])) {
         $defaults = self::_defaultConfig($sessionConfig['defaults']);
         if ($defaults) {
             $sessionConfig = Hash::merge($defaults, $sessionConfig);
         }
     }
     if (!isset($sessionConfig['ini']['session.cookie_secure']) && env('HTTPS')) {
         $sessionConfig['ini']['session.cookie_secure'] = 1;
     }
     if (isset($sessionConfig['timeout']) && !isset($sessionConfig['cookieTimeout'])) {
         $sessionConfig['cookieTimeout'] = $sessionConfig['timeout'];
     }
     if (!isset($sessionConfig['ini']['session.cookie_lifetime'])) {
         $sessionConfig['ini']['session.cookie_lifetime'] = $sessionConfig['cookieTimeout'] * 60;
     }
     if (!isset($sessionConfig['ini']['session.name'])) {
         $sessionConfig['ini']['session.name'] = $sessionConfig['cookie'];
     }
     self::$_cookieName = $sessionConfig['ini']['session.name'];
     if (!empty($sessionConfig['handler'])) {
         $sessionConfig['ini']['session.save_handler'] = 'user';
     }
     if (!isset($sessionConfig['ini']['session.gc_maxlifetime'])) {
         $sessionConfig['ini']['session.gc_maxlifetime'] = $sessionConfig['timeout'] * 60;
     }
     if (!isset($sessionConfig['ini']['session.cookie_httponly'])) {
         $sessionConfig['ini']['session.cookie_httponly'] = 1;
     }
     if (empty($_SESSION)) {
         if (!empty($sessionConfig['ini']) && is_array($sessionConfig['ini'])) {
             foreach ($sessionConfig['ini'] as $setting => $value) {
                 if (ini_set($setting, $value) === false) {
                     throw new CakeSessionException(__d('cake_dev', 'Unable to configure the session, setting %s failed.', $setting));
                 }
             }
         }
     }
     if (!empty($sessionConfig['handler']) && !isset($sessionConfig['handler']['engine'])) {
         call_user_func_array('session_set_save_handler', $sessionConfig['handler']);
     }
     if (!empty($sessionConfig['handler']['engine'])) {
         $handler = self::_getHandler($sessionConfig['handler']['engine']);
         session_set_save_handler(array($handler, 'open'), array($handler, 'close'), array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'));
     }
     Configure::write('Session', $sessionConfig);
     self::$sessionTime = self::$time + $sessionConfig['timeout'] * 60;
 }
開發者ID:kyme-online,項目名稱:Ramesh-Photography,代碼行數:58,代碼來源:CakeSession.php


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