当前位置: 首页>>代码示例>>PHP>>正文


PHP sfSessionStorage类代码示例

本文整理汇总了PHP中sfSessionStorage的典型用法代码示例。如果您正苦于以下问题:PHP sfSessionStorage类的具体用法?PHP sfSessionStorage怎么用?PHP sfSessionStorage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了sfSessionStorage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFavorites

 /**
  * @return ArrayObject
  */
 public static function getFavorites()
 {
     $session = new sfSessionStorage();
     if ($session->read('favorites') === null) {
         $session->initialize(array('session_cookie_lifetime' => 2592000));
         $session->write('favorites', new ArrayObject(array()));
     }
     return $session->read('favorites');
 }
开发者ID:HHirano,项目名称:TEST100,代码行数:12,代码来源:Utils.php

示例2: initialize

 /**
  * Available options:
  *
  *   * db_table:    The database table in which session data will be stored
  *   * database:    The sfDatabase object to use
  *   * db_id_col:   The database column in which the session id will be stored (sess_id by default)
  *   * db_data_col: The database column in which the session data will be stored (sess_data by default)
  *   * db_time_col: The database column in which the session timestamp will be stored (sess_time by default)
  *
  * @param  array $options  An associative array of options
  *
  * @see sfSessionStorage
  */
 public function initialize($options = array())
 {
     $options = array_merge(array('db_id_col' => 'sess_id', 'db_data_col' => 'sess_data', 'db_time_col' => 'sess_time'), $options);
     // disable auto_start
     $options['auto_start'] = false;
     // initialize the parent
     parent::initialize($options);
     if (!isset($this->options['db_table'])) {
         throw new sfInitializationException('You must provide a "db_table" option to sfDatabaseSessionStorage.');
     }
     if (!isset($this->options['database'])) {
         throw new sfInitializationException('You must provide a "database" option to sfDatabaseSessionStorage.');
     }
     // use this object as the session handler
     session_set_save_handler(array($this, 'sessionOpen'), array($this, 'sessionClose'), array($this, 'sessionRead'), array($this, 'sessionWrite'), array($this, 'sessionDestroy'), array($this, 'sessionGC'));
     // start our session
     session_start();
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:31,代码来源:sfDatabaseSessionStorage.class.php

示例3: dirname

 */
$app = 'frontend';
require_once dirname(__FILE__) . '/../../bootstrap/functional.php';
ob_start();
$_test_dir = realpath(dirname(__FILE__) . '/../../');
require_once $_test_dir . '/../lib/vendor/lime/lime.php';
sfConfig::set('sf_symfony_lib_dir', realpath($_test_dir . '/../lib'));
$t = new lime_test(8, new lime_output_color());
// initialize the storage
try {
    $storage = new sfSessionStorage();
    $t->pass('->__construct() does not throw an exception when not provided with options');
} catch (InvalidArgumentException $e) {
    $t->fail('->__construct() Startup failure');
}
$storage = new sfSessionStorage();
$t->ok($storage instanceof sfStorage, '->__construct() is an instance of sfStorage');
$storage->write('test', 123);
$t->is($storage->read('test'), 123, '->read() can read data that has been written to storage');
// regenerate()
$oldSessionData = 'foo:bar';
$key = md5($oldSessionData);
$storage->write($key, $oldSessionData);
$session_id = session_id();
$storage->regenerate(false);
$t->is($storage->read($key), $oldSessionData, '->regenerate(false) regenerated the session with a different session id - this class by default doesn\'t regen the id');
$t->isnt(session_id(), $session_id, '->regenerate(false) regenerated the session with a different session id');
$storage->regenerate(true);
$t->is($storage->read($key), $oldSessionData, '->regenerate(true) regenerated the session with a different session id and destroyed data');
$t->isnt(session_id(), $session_id, '->regenerate(true) regenerated the session with a different session id');
$storage->remove($key);
开发者ID:mediasadc,项目名称:alba,代码行数:31,代码来源:sfSessionStorageTest.php

示例4: initialize

 public function initialize($options = null)
 {
     if (session_id() != '') {
         self::$sessionStarted = true;
     }
     parent::initialize($options);
 }
开发者ID:runopencode,项目名称:diem-extended,代码行数:7,代码来源:dmSessionStorage.class.php

示例5: initialize

 /**
  * Available options:
  *
  *  * session_name:            The cookie name (symfony by default)
  *  * session_id:              The session id (null by default)
  *  * auto_start:              Whether to start the session (true by default)
  *  * session_cookie_lifetime: Cookie lifetime
  *  * session_cookie_path:     Cookie path
  *  * session_cookie_domain:   Cookie domain
  *  * session_cookie_secure:   Cookie secure
  *  * session_cookie_httponly: Cookie http only (only for PHP >= 5.2)
  *
  * The default values for all 'session_cookie_*' options are those returned by the session_get_cookie_params() function
  *
  * @param array $options  An associative array of options
  *
  * @see sfStorage
  */
 public function initialize($options = null)
 {
     $cookieDefaults = session_get_cookie_params();
     $options = array_merge(array('session_name' => 'symfony', 'session_id' => null, 'auto_start' => true, 'session_cookie_lifetime' => $cookieDefaults['lifetime'], 'session_cookie_path' => $cookieDefaults['path'], 'session_cookie_domain' => $cookieDefaults['domain'], 'session_cookie_secure' => $cookieDefaults['secure'], 'session_cookie_httponly' => isset($cookieDefaults['httponly']) ? $cookieDefaults['httponly'] : false), $options);
     // initialize parent
     parent::initialize($options);
     // set session name
     $sessionName = $this->options['session_name'];
     session_name($sessionName);
     if (!(bool) ini_get('session.use_cookies') && ($sessionId = $this->options['session_id'])) {
         session_id($sessionId);
     }
     $lifetime = $this->options['session_cookie_lifetime'];
     $path = $this->options['session_cookie_path'];
     $domain = $this->options['session_cookie_domain'];
     $secure = $this->options['session_cookie_secure'];
     $httpOnly = $this->options['session_cookie_httponly'];
     if (version_compare(phpversion(), '5.2', '>=')) {
         session_set_cookie_params($lifetime, $path, $domain, $secure, $httpOnly);
     } else {
         session_set_cookie_params($lifetime, $path, $domain, $secure);
     }
     if ($this->options['auto_start'] && !self::$sessionStarted) {
         session_start();
         self::$sessionStarted = true;
     }
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:45,代码来源:sfSessionStorage.class.php

示例6: initialize

 /**
  * Available options:
  *
  *  * session_name:            The cookie name (symfony by default)
  *  * session_id:              The session id (null by default)
  *  * auto_start:              Whether to start the session (true by default)
  *  * session_cookie_lifetime: Cookie lifetime
  *  * session_cookie_path:     Cookie path
  *  * session_cookie_domain:   Cookie domain
  *  * session_cookie_secure:   Cookie secure
  *  * session_cookie_httponly: Cookie http only (only for PHP >= 5.2)
  *
  * The default values for all 'session_cookie_*' options are those returned by the session_get_cookie_params() function
  *
  * @param array $options  An associative array of options
  *
  * @see sfStorage
  */
 public function initialize($options = null)
 {
     //@todo: for photo upload make care about secure
     if ($sessionId = $options['session_id']) {
         session_id($sessionId);
     }
     parent::initialize($options);
     //        print_r($_SESSION);
 }
开发者ID:limitium,项目名称:uberlov,代码行数:27,代码来源:sfHtSessionStorage.class.php

示例7: initialize

 public function initialize($options = null)
 {
     // http://trac.symfony-project.org/ticket/5683
     if (!isset($options['session_cookie_path'])) {
         $options['session_cookie_path'] = sfContext::getInstance()->request->getRelativeUrlRoot();
         if (1 > strlen($options['session_cookie_path'])) {
             $options['session_cookie_path'] = '/';
         }
     }
     parent::initialize($options);
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:11,代码来源:QubitSessionStorage.class.php

示例8: initialize

 /**
  * @return null
  */
 public function initialize($options = null)
 {
     if (sfJpMobile::isMobile()) {
         ini_set("session.use_trans_sid", 1);
         ini_set("session.use_cookies", 0);
         ini_set("session.use_only_cookies", 0);
     } else {
         ini_set("session.use_trans_sid", 0);
         ini_set("session.use_cookies", 1);
     }
     parent::initialize($options);
 }
开发者ID:pontuyo,项目名称:takutomo-mixi-appli,代码行数:15,代码来源:sfJpMobileSessionStorage.class.php

示例9: initialize

 public function initialize($options = null)
 {
     $request = sfContext::getInstance()->getRequest();
     // work-around for uploadify
     if ($request->getParameter('uploadify') == "onUpload") {
         $sessionName = $options["session_name"];
         if ($value = $request->getParameter($sessionName)) {
             session_name($sessionName);
             session_id($value);
         }
     }
     parent::initialize($options);
 }
开发者ID:noikiy,项目名称:qdpm,代码行数:13,代码来源:qdPMSessionStorage.php

示例10: initialize

 public function initialize($options = null)
 {
     $context = sfContext::getInstance();
     $sessionName = $options["session_name"];
     if ($value = $context->getRequest()->getParameter($sessionName)) {
         session_name($sessionName);
         session_id($value);
     }
     if (isset($options['session_cookie_domain']) && '.' == $options['session_cookie_domain']) {
         preg_match('/([^.]+\\.[^.]+)$/', $_SERVER['SERVER_NAME'], $matches);
         $options['session_cookie_domain'] = '.' . $matches[1];
     }
     parent::initialize($options);
 }
开发者ID:pycmam,项目名称:myImageUploadPlugin,代码行数:14,代码来源:myImageUploadSessionStorage.class.php

示例11: initialize

 public function initialize($options = null)
 {
     if ($this->transSidFor(sfContext::getInstance()->getRequest())) {
         $sessionName = isset($options['session_name']) ? $options['session_name'] : 'symfony';
         if ($value = sfContext::getInstance()->getRequest()->getParameter($sessionName)) {
             if (sfConfig::get('sf_logging_enabled')) {
                 sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($this, 'application.log', array(sprintf('Changing session name "%s" to "%s"', $sessionName, $value))));
             }
             session_name($sessionName);
             session_id($value);
         }
     }
     parent::initialize($options);
 }
开发者ID:ner0tic,项目名称:ddWidgetFormInputUploadify,代码行数:14,代码来源:ddSessionStorageUploadify.class.php

示例12: initialize

 public function initialize($parameters = null)
 {
     //Shitty work-around for swfuploader
     $context = sfContext::getInstance();
     $request = sfContext::getInstance()->getRequest();
     if ($request->getParameter('action') == "swfupload") {
         $sessionName = $parameters["session_name"];
         if ($value = $context->getRequest()->getParameter($sessionName)) {
             session_name($sessionName);
             session_id($value);
         }
     }
     parent::initialize($parameters);
 }
开发者ID:vcgato29,项目名称:poff,代码行数:14,代码来源:MySessionStorage.php

示例13: initialize

 /**
  * Initializes this Storage instance.
  *
  * @param sfContext A sfContext instance
  * @param array     An associative array of initialization parameters
  *
  * @return boolean true, if initialization completes successfully, otherwise false
  *
  * @throws <b>InitializationException</b> If an error occurs while initializing this Storage
  */
 public function initialize($context, $parameters = null)
 {
     // disable auto_start
     $parameters['auto_start'] = false;
     // initialize the parent
     parent::initialize($context, $parameters);
     if (!$this->getParameterHolder()->has('db_table')) {
         // missing required 'db_table' parameter
         $error = 'Factory configuration file is missing required "db_table" parameter for the Storage category';
         throw new sfInitializationException($error);
     }
     // use this object as the session handler
     session_set_save_handler(array($this, 'sessionOpen'), array($this, 'sessionClose'), array($this, 'sessionRead'), array($this, 'sessionWrite'), array($this, 'sessionDestroy'), array($this, 'sessionGC'));
     // start our session
     session_start();
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:26,代码来源:sfPDOSessionStorage.class.php

示例14: initialize

 public function initialize($options = null)
 {
     $auto_start = !is_array($options) || !array_key_exists('auto_start', $options) || $options['auto_start'] != false;
     $session_name = is_array($options) && array_key_exists('session_name', $options) ? $options['session_name'] : 'symfony';
     $delay_auto_start = false;
     if ($auto_start && empty($_COOKIE[$session_name])) {
         if (!is_array($options)) {
             $options = array();
         }
         $options['auto_start'] = false;
         $delay_auto_start = true;
     }
     parent::initialize($options);
     if ($delay_auto_start) {
         $this->options['auto_start'] = true;
     }
 }
开发者ID:uniteddiversity,项目名称:policat,代码行数:17,代码来源:policatSessionStorage.class.php

示例15: initialize

 public function initialize($context, $parameters = null)
 {
     parent::initialize($context, $parameters);
     // UserAgent取得
     $agent = new Net_UserAgent_Mobile();
     //$agent = $this->getContext()->getRequest()->getAttribute('userAgent');
     if ($agent->isDoCoMo()) {
         ini_set("session.use_trans_sid", 1);
         ini_set("session.use_cookies", 0);
     } else {
         if ($agent->isSoftBank()) {
             ini_set("session.use_trans_sid", 0);
             ini_set("session.use_cookies", 1);
         } else {
             if ($agent->isEZweb()) {
                 ini_set("session.use_trans_sid", 0);
                 ini_set("session.use_cookies", 1);
             }
         }
     }
 }
开发者ID:pontuyo,项目名称:takutomo-mixi-appli,代码行数:21,代码来源:mobileSessionStorage.class.php


注:本文中的sfSessionStorage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。