本文整理汇总了PHP中sfSessionStorage::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP sfSessionStorage::initialize方法的具体用法?PHP sfSessionStorage::initialize怎么用?PHP sfSessionStorage::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfSessionStorage
的用法示例。
在下文中一共展示了sfSessionStorage::initialize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public function initialize($options = null)
{
if (session_id() != '') {
self::$sessionStarted = true;
}
parent::initialize($options);
}
示例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();
}
示例3: 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);
}
示例4: 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');
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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);
}
示例9: 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);
}
示例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);
}
示例11: initialize
/**
* Available options:
*
* - host: The default host (default to localhost)
* - port: The port for the default server (default to 11211)
* - persistent: true if the connection must be persistent, false otherwise (true by default)
*
* @param array $options An associative array of options
*
* @see sfSessionStorage
* @see sfMemcacheCache
*/
public function initialize($options = array())
{
// disable auto_start
$options['auto_start'] = false;
// initialize the parent
parent::initialize($options);
if (!class_exists('Memcache')) {
throw new sfInitializationException('You must have memcache installed and enabled to use sfMemcacheCache class.');
}
$this->memcache = new Memcache();
// 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();
}
示例12: 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();
}
示例13: 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;
}
}
示例14: 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);
}
}
}
}