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


PHP session_name函数代码示例

本文整理汇总了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.
     }
 }
开发者ID:x33n,项目名称:ImpressPages,代码行数:35,代码来源:Application.php

示例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();
    }
}
开发者ID:rgooler,项目名称:personal-puppet,代码行数:39,代码来源:utils.php

示例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();
 }
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:26,代码来源:class.ostsession.php

示例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;
     }
 }
开发者ID:ducdm87,项目名称:gamelienminh,代码行数:30,代码来源:UserForm.php

示例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));
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:35,代码来源:FileController.php

示例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;
}
开发者ID:amjadtbssm,项目名称:website,代码行数:28,代码来源:adodb-session.php

示例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);
     }
 }
开发者ID:clee03,项目名称:metal,代码行数:26,代码来源:Session.php

示例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));
 }
开发者ID:CE-Webmaster,项目名称:CE-Hub,代码行数:29,代码来源:GalleryController.php

示例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);
     }
 }
开发者ID:woakes070048,项目名称:mautic,代码行数:40,代码来源:CoreSubscriber.php

示例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();
     }
 }
开发者ID:CaioFlavio,项目名称:catalogapp,代码行数:28,代码来源:auth.php

示例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;
     }
 }
开发者ID:atlantis3001,项目名称:nofussframework,代码行数:25,代码来源:Session.php

示例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();
     }
 }
开发者ID:qqalexqq,项目名称:Projects_645,代码行数:30,代码来源:class.SessionManager.php

示例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();
     }
 }
开发者ID:brandonfrancis,项目名称:scsapi,代码行数:28,代码来源:session.php

示例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);
     }
 }
开发者ID:eokyere,项目名称:elgg,代码行数:34,代码来源:pfcuserconfig.class.php

示例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;
     }
 }
开发者ID:rousseau-christopher,项目名称:equinox-core,代码行数:33,代码来源:Container.php


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