本文整理汇总了PHP中session_name函数的典型用法代码示例。如果您正苦于以下问题:PHP session_name函数的具体用法?PHP session_name怎么用?PHP session_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了session_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareEnvironment
/**
* @ignore
* @param array $options
*/
public function prepareEnvironment($options = array())
{
if (empty($options['skipErrorHandler'])) {
set_error_handler(array('Ip\\Internal\\ErrorHandler', 'ipErrorHandler'));
}
if (empty($options['skipError'])) {
if (ipConfig()->showErrors()) {
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', '1');
} else {
ini_set('display_errors', '0');
}
}
if (empty($options['skipSession'])) {
if (session_id() == '' && !headers_sent()) {
//if session hasn't been started yet
session_name(ipConfig()->get('sessionName'));
if (!ipConfig()->get('disableHttpOnlySetting')) {
ini_set('session.cookie_httponly', 1);
}
session_start();
}
}
if (empty($options['skipEncoding'])) {
mb_internal_encoding(ipConfig()->get('charset'));
}
if (empty($options['skipTimezone'])) {
date_default_timezone_set(ipConfig()->get('timezone'));
//PHP 5 requires timezone to be set.
}
}
示例2: session_init
/**
* Initialize session.
* @param boolean $keepopen keep session open? The default is
* to close the session after $_SESSION has been populated.
* @uses $_SESSION
*/
function session_init($keepopen = false)
{
$settings = new phpVBoxConfigClass();
// Sessions provided by auth module?
if (@$settings->auth->capabilities['sessionStart']) {
call_user_func(array($settings->auth, $settings->auth->capabilities['sessionStart']), $keepopen);
return;
}
// No session support? No login...
if (@$settings->noAuth || !function_exists('session_start')) {
global $_SESSION;
$_SESSION['valid'] = true;
$_SESSION['authCheckHeartbeat'] = time();
$_SESSION['admin'] = true;
return;
}
// start session
session_start();
// Session is auto-started by PHP?
if (!ini_get('session.auto_start')) {
ini_set('session.use_trans_sid', 0);
ini_set('session.use_only_cookies', 1);
// Session path
if (isset($settings->sessionSavePath)) {
session_save_path($settings->sessionSavePath);
}
session_name(isset($settings->session_name) ? $settings->session_name : md5('phpvbx' . $_SERVER['DOCUMENT_ROOT'] . $_SERVER['HTTP_USER_AGENT']));
session_start();
}
if (!$keepopen) {
session_write_close();
}
}
示例3: osTicketSession
function osTicketSession($ttl = 0)
{
$this->ttl = $ttl ?: ini_get('session.gc_maxlifetime') ?: SESSION_TTL;
// Set osTicket specific session name.
session_name('OSTSESSID');
// Forced cleanup on shutdown
register_shutdown_function('session_write_close');
// Set session cleanup time to match TTL
ini_set('session.gc_maxlifetime', $ttl);
if (OsticketConfig::getDBVersion()) {
return session_start();
}
# Cookies
// Avoid setting a cookie domain without a dot, thanks
// http://stackoverflow.com/a/1188145
$domain = null;
if (isset($_SERVER['HTTP_HOST']) && strpos($_SERVER['HTTP_HOST'], '.') !== false && !Validator::is_ip($_SERVER['HTTP_HOST'])) {
// Remote port specification, as it will make an invalid domain
list($domain) = explode(':', $_SERVER['HTTP_HOST']);
}
session_set_cookie_params($ttl, ROOT_PATH, $domain, osTicket::is_https());
//Set handlers.
session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
//Start the session.
session_start();
}
示例4: login
/**
* Logs in the user using the given username and password in the model.
* @return boolean whether login is successful
*/
public function login()
{
$app = Yii::app();
if ($this->_identity === null) {
$this->_identity = new UserIdentity($this->username, $this->password);
$this->_identity->authenticate();
}
if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
if (isset($_POST['LoginForm']['rememberMe']) and $_POST['LoginForm']['rememberMe'] == 1) {
$duration = time() + 86400 * 30;
// 30 days
$cookie = new CHttpCookie('remember_admin', 1, array("expire" => $duration));
$app->getRequest()->getCookies()->add($cookie->name, $cookie);
} else {
$cookie = new CHttpCookie('remember_admin', 0, array("expire" => time() - 1));
$app->getRequest()->getCookies()->add($cookie->name, $cookie);
$duration = 0;
}
$app->user->login($this->_identity, $duration);
$cookie = new CHttpCookie(session_name(), session_id(), array("expire" => $duration));
$app->getRequest()->getCookies()->add($cookie->name, $cookie);
return true;
} else {
return false;
}
}
示例5: uploadAction
/**
* Upload file controller action
*/
public function uploadAction()
{
$type = $this->getRequest()->getParam('type');
$tmpPath = '';
if ($type == 'samples') {
$tmpPath = Mage_Downloadable_Model_Sample::getBaseTmpPath();
} elseif ($type == 'links') {
$tmpPath = Mage_Downloadable_Model_Link::getBaseTmpPath();
} elseif ($type == 'link_samples') {
$tmpPath = Mage_Downloadable_Model_Link::getBaseSampleTmpPath();
}
$result = array();
try {
$uploader = new Mage_Core_Model_File_Uploader($type);
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$result = $uploader->save($tmpPath);
/**
* Workaround for prototype 1.7 methods "isJSON", "evalJSON" on Windows OS
*/
$result['tmp_name'] = str_replace(DS, "/", $result['tmp_name']);
$result['path'] = str_replace(DS, "/", $result['path']);
if (isset($result['file'])) {
$fullPath = rtrim($tmpPath, DS) . DS . ltrim($result['file'], DS);
Mage::helper('core/file_storage_database')->saveFile($fullPath);
}
$result['cookie'] = array('name' => session_name(), 'value' => $this->_getSession()->getSessionId(), 'lifetime' => $this->_getSession()->getCookieLifetime(), 'path' => $this->_getSession()->getCookiePath(), 'domain' => $this->_getSession()->getCookieDomain());
} catch (Exception $e) {
$result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
示例6: adodb_session_regenerate_id
function adodb_session_regenerate_id()
{
$conn =& ADODB_Session::_conn();
if (!$conn) {
return false;
}
$old_id = session_id();
if (function_exists('session_regenerate_id')) {
session_regenerate_id();
} else {
session_id(md5(uniqid(rand(), true)));
$ck = session_get_cookie_params();
setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
//@session_start();
}
$new_id = session_id();
$ok =& $conn->Execute('UPDATE ' . ADODB_Session::table() . ' SET sesskey=' . $conn->qstr($new_id) . ' WHERE sesskey=' . $conn->qstr($old_id));
/* it is possible that the update statement fails due to a collision */
if (!$ok) {
session_id($old_id);
if (empty($ck)) {
$ck = session_get_cookie_params();
}
setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
return false;
}
return true;
}
示例7: init
public function init()
{
/** @var Uri $uri */
$uri = $this->grav['uri'];
$config = $this->grav['config'];
$is_admin = false;
$session_timeout = $config->get('system.session.timeout', 1800);
$session_path = $config->get('system.session.path', '/' . ltrim($uri->rootUrl(false), '/'));
// Activate admin if we're inside the admin path.
if ($config->get('plugins.admin.enabled')) {
$route = $config->get('plugins.admin.route');
$base = '/' . trim($route, '/');
if (substr($uri->route(), 0, strlen($base)) == $base) {
$session_timeout = $config->get('plugins.admin.session.timeout', 1800);
$is_admin = true;
}
}
if ($config->get('system.session.enabled') || $is_admin) {
// Define session service.
parent::__construct($session_timeout, $session_path);
$unique_identifier = GRAV_ROOT;
$this->setName($config->get('system.session.name', 'grav_site') . '-' . substr(md5($unique_identifier), 0, 7) . ($is_admin ? '-admin' : ''));
$this->start();
setcookie(session_name(), session_id(), time() + $session_timeout, $session_path);
}
}
示例8: uploadAction
public function uploadAction()
{
try {
$pattern = "/([0-9]+\\.[0-9]+\\.[0-9]+)(?:\\.[0-9]+)*/";
$matches = array();
preg_match($pattern, Mage::getVersion(), $matches);
if (version_compare($matches[1], '1.5.1', '<')) {
$uploader = new Varien_File_Uploader('image');
} else {
$uploader = new Mage_Core_Model_File_Uploader('image');
}
$uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
$uploader->addValidateCallback('catalog_product_image', Mage::helper('catalog/image'), 'validateUploadFile');
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
$result = $uploader->save($this->getMagicslideshowBaseMediaPath());
/**
* Workaround for prototype 1.7 methods "isJSON", "evalJSON" on Windows OS
*/
$result['tmp_name'] = str_replace(DS, "/", $result['tmp_name']);
$result['path'] = str_replace(DS, "/", $result['path']);
$result['url'] = $this->getMagicslideshowMediaUrl($result['file']);
$result['file'] = $result['file'];
$result['cookie'] = array('name' => session_name(), 'value' => $this->_getSession()->getSessionId(), 'lifetime' => $this->_getSession()->getCookieLifetime(), 'path' => $this->_getSession()->getCookiePath(), 'domain' => $this->_getSession()->getCookieDomain());
} catch (Exception $e) {
$result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
示例9: onKernelRequest
/**
* Set default timezone/locale
*
* @param GetResponseEvent $event
*
* @return void
*/
public function onKernelRequest(GetResponseEvent $event)
{
// Set the user's default locale
$request = $event->getRequest();
if (!$request->hasPreviousSession()) {
return;
}
$currentUser = $this->factory->getUser();
//set the user's timezone
if (is_object($currentUser)) {
$tz = $currentUser->getTimezone();
}
if (empty($tz)) {
$tz = $this->params['default_timezone'];
}
date_default_timezone_set($tz);
if (!($locale = $request->attributes->get('_locale'))) {
if (is_object($currentUser)) {
$locale = $currentUser->getLocale();
}
if (empty($locale)) {
$locale = $this->params['locale'];
}
}
$request->setLocale($locale);
// Set a cookie with session name for CKEditor's filemanager
$sessionName = $request->cookies->get('mautic_session_name');
if ($sessionName != session_name()) {
/** @var \Mautic\CoreBundle\Helper\CookieHelper $cookieHelper */
$cookieHelper = $this->factory->getHelper('cookie');
$cookieHelper->setCookie('mautic_session_name', session_name(), null);
}
}
示例10: sessionStart
static function sessionStart($name, $limit = 0, $path = '/', $domain = null, $secure = null)
{
// Set the cookie name
session_name($name . '_Session');
// Set SSL level
$https = isset($secure) ? $secure : isset($_SERVER['HTTPS']);
// Set session cookie options
session_set_cookie_params($limit, $path, $domain, $https, true);
session_start();
// Make sure the session hasn't expired, and destroy it if it has
if (self::validateSession()) {
// Check to see if the session is new or a hijacking attempt
if (!self::preventHijacking()) {
// Reset session data and regenerate id
$_SESSION = array();
$_SESSION['IPaddress'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
self::regenerateSession();
// Give a 5% chance of the session id changing on any request
} elseif (rand(1, 100) <= 5) {
self::regenerateSession();
}
} else {
$_SESSION = array();
session_destroy();
session_start();
}
}
示例11: start
public static function start()
{
$config = Registry::get('config');
if (isset($config->session)) {
// optional parameters sent to the constructor
if (isset($config->session->params)) {
$sessionParams = $config->session->params;
}
if (is_object($config->session->handler)) {
$sessionHandler = self::factory($config->session->handler->namespace, $config->session->handler->class, $sessionParams, $config->session->lifetime);
} else {
$sessionHandler = self::factory('Nf\\Session', $config->session->handler, $sessionParams, $config->session->lifetime);
}
session_name($config->session->cookie->name);
session_set_cookie_params(0, $config->session->cookie->path, $config->session->cookie->domain, false, true);
session_set_save_handler(array(&$sessionHandler, 'open'), array(&$sessionHandler, 'close'), array(&$sessionHandler, 'read'), array(&$sessionHandler, 'write'), array(&$sessionHandler, 'destroy'), array(&$sessionHandler, 'gc'));
register_shutdown_function('session_write_close');
session_start();
// session_regenerate_id(true);
Registry::set('session', $sessionHandler);
return $sessionHandler;
} else {
return false;
}
}
示例12: sessionStart
static function sessionStart($name, $limit = 0, $path = '/', $domain = null, $secure = null)
{
// Set the cookie name before we start.
session_name($name . '_Session');
// Set the domain to default to the current domain.
$domain = isset($domain) ? $domain : isset($_SERVER['SERVER_NAME']);
// Set the default secure value to whether the site is being accessed with SSL
$https = isset($secure) ? $secure : isset($_SERVER['HTTPS']);
// Set the cookie settings and start the session
session_set_cookie_params($limit, $path, $domain, $secure, true);
session_start();
// Make sure the session hasn't expired, and destroy it if it has
if (self::validateSession()) {
// Check to see if the session is new or a hijacking attempt
if (!self::preventHijacking()) {
// Reset session data and regenerate id
$_SESSION = array();
$_SESSION['IPaddress'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
self::regenerateSession();
// Give a 5% chance of the session id changing on any request
} elseif (rand(1, 100) <= 5) {
self::regenerateSession();
}
} else {
$_SESSION = array();
session_destroy();
session_start();
}
}
示例13: initialize
/**
* Initializes the session system.
*/
private static function initialize()
{
// Make sure it's not initialized already
if (self::$initialized) {
return;
}
// See if we were given a session id explicitly
// If so we also need a matching token to allow it
$setSid = false;
if (Input::exists('_sid')) {
session_id(Input::get('_sid'));
$setSid = true;
}
// Start the default PHP session
self::$prefix = crc32(APP_SALT) . '_';
session_name('session');
session_start();
// Set the initialized flag
self::$initialized = true;
// Make sure the token is good before we allow
// explicit session id setting
if ($setSid) {
Auth::checkToken();
}
}
示例14: pfcUserConfig
function pfcUserConfig()
{
$c =& pfcGlobalConfig::Instance();
// start the session : session is used for locking purpose and cache purpose
session_name("phpfreechat");
if (session_id() == "") {
session_start();
}
// the nickid is a public identifier shared between all the chatters
// this is why the session_id must not be assigned directly to the nickid
$this->nickid = sha1(session_id());
// user parameters are cached in sessions
$this->_getParam("nick");
if (!isset($this->nick)) {
$this->_setParam("nick", "");
}
// setup a blank nick if it is not yet in session
$this->_getParam("active");
if (!isset($this->active)) {
$this->_setParam("active", false);
}
$this->_getParam("channels");
if (!isset($this->channels)) {
$this->_setParam("channels", array());
}
$this->_getParam("privmsg");
if (!isset($this->privmsg)) {
$this->_setParam("privmsg", array());
}
$this->_getParam("serverid");
if (!isset($this->privmsg)) {
$this->_setParam("serverid", $c->serverid);
}
}
示例15: getBeanInstance
private function getBeanInstance(BeanDefinition $bean)
{
switch ($bean->getScope()) {
case BeanDefinition::SCOPE_SINGLETON:
if (array_key_exists($bean->getId(), $this->singletonInstances)) {
return $this->singletonInstances[$bean->getId()];
}
$instance = $this->createBean($bean, true);
return $instance;
break;
case BeanDefinition::SCOPE_PROTOTYPE:
return $this->createBean($bean);
break;
case BeanDefinition::SCOPE_SESSION:
if (!self::$sessionInitialized) {
self::$sessionInitialized = true;
session_cache_expire(180);
session_name('equinox');
session_start();
}
if (array_key_exists('equinox_ioc', $_SESSION) && array_key_exists($bean->getId(), $_SESSION['equinox_ioc'])) {
return $_SESSION['equinox_ioc'][$bean->getId()];
} else {
$instance = $this->createBean($bean);
$_SESSION['equinox_ioc'][$bean->getId()] = $instance;
return $instance;
}
break;
default:
throw new IocException("Unknow scope ({$bean->getScope()}) for bean ({$bean->getId()})");
break;
}
}