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


PHP session_get_cookie_params函数代码示例

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


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

示例1: start

 static function start()
 {
     include_once __DIR__ . '/sessionDrivers/' . Settings::$sessionDriver . '.php';
     //self::$driver = new Settings::$sessionDriver();
     //session_set_save_handler(array(self::$driver, 'open'),array(self::$driver, 'close'),array(self::$driver, 'read'),
     //            array(self::$driver, 'write'),array(self::$driver, 'destroy'),array(self::$driver, 'gc'));
     register_shutdown_function('session_write_close');
     if (in_array(Settings::$session_hash, hash_algos())) {
         ini_set('session.hash_function', Settings::$session_hash);
     }
     ini_set('session.hash_bits_per_character', Settings::$hash_bits_per_character);
     $cookieParams = session_get_cookie_params();
     session_set_cookie_params(Settings::$sessionLifetime, $cookieParams["path"], $cookieParams["domain"], Settings::$secure, Settings::$httpOnly);
     session_name(Settings::$NAME);
     //буферизуем заголовок
     ob_start();
     //включаем CORS, если указано в настройках /*
     if (isset(Settings::$CORS) && Settings::$CORS && !empty($_SERVER['HTTP_ORIGIN'])) {
         header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
         header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
         header('Access-Control-Max-Age: 1000');
         header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
     }
     //включаем сессию
     session_start();
     ob_end_flush();
     //посылаем заголовок
 }
开发者ID:pdanver,项目名称:mir-ndv,代码行数:28,代码来源:Session.php

示例2: init

 /**
  * Initialize session
  */
 public static function init()
 {
     // Force cookie path (but do not change lifetime)
     $cookie = session_get_cookie_params();
     // Default cookie expiration and path.
     $cookiedir = '';
     if (dirname($_SERVER['SCRIPT_NAME']) != '/') {
         $cookiedir = dirname($_SERVER["SCRIPT_NAME"]) . '/';
     }
     $ssl = false;
     if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
         $ssl = true;
     }
     session_set_cookie_params($cookie['lifetime'], $cookiedir, $cookie['domain'], $ssl);
     // Use cookies to store session.
     ini_set('session.use_cookies', 1);
     // Force cookies for session  (phpsessionID forbidden in URL)
     ini_set('session.use_only_cookies', 1);
     if (!session_id()) {
         // Prevent php to use sessionID in URL if cookies are disabled.
         ini_set('session.use_trans_sid', false);
         if (!empty(self::$sessionName)) {
             session_name(self::$sessionName);
         }
         session_start();
     }
 }
开发者ID:Scorry,项目名称:readityourself,代码行数:30,代码来源:Session.php

示例3: _set_session_start_

function _set_session_start_()
{
    global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS;
    $var_session = true;
    if (isset($HTTP_GET_VARS[_set_session_name_()])) {
        if (preg_match("/^[a-zA-Z0-9]+\$/", $HTTP_GET_VARS[_set_session_name_()]) == false) {
            unset($HTTP_GET_VARS[_set_session_name_()]);
            $var_session = false;
        }
    } elseif (isset($HTTP_POST_VARS[_set_session_name_()])) {
        if (preg_match("/^[a-zA-Z0-9]+\$/", $HTTP_POST_VARS[_set_session_name_()]) == false) {
            unset($HTTP_POST_VARS[_set_session_name_()]);
            $var_session = false;
        }
    } elseif (isset($HTTP_COOKIE_VARS[_set_session_name_()])) {
        if (preg_match("/^[a-zA-Z0-9]+\$/", $HTTP_COOKIE_VARS[_set_session_name_()]) == false) {
            $var_session_data = session_get_cookie_params();
            setcookie(_set_session_name_(), "", time() - 42000, $var_session_data["path"], $var_session_data["domain"]);
            $var_session = false;
        }
    }
    if ($var_session == false) {
        _set_location_(def_application_home);
    }
    return session_start();
}
开发者ID:ocpyosep78,项目名称:ORDER-SMS,代码行数:26,代码来源:function_session.php

示例4: iniciarSesion

 function iniciarSesion($session_name, $secure)
 {
     // Make sure the session cookie is not accessable via javascript.
     $httpunico = true;
     // Hash algorithm to use for the sessionid. (use hash_algos() to get a list of available hashes.)
     $sesion_hash = 'sha512';
     // Check if hash is available
     if (in_array($sesion_hash, hash_algos())) {
         // Set the has function.
         ini_set('session.hash_function', $sesion_hash);
     }
     // How many bits per character of the hash.
     // The possible values are '4' (0-9, a-f), '5' (0-9, a-v), and '6' (0-9, a-z, A-Z, "-", ",").
     ini_set('session.hash_bits_per_character', 5);
     // Force the session to only use cookies, not URL variables.
     ini_set('session.use_only_cookies', 1);
     // Get session cookie parameters
     $cookieParams = session_get_cookie_params();
     // Set the parameters
     session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httpunico);
     // Change the session name
     session_name($session_name);
     // Now we cat start the session
     session_start();
     // This line regenerates the session and delete the old one.
     // It also generates a new encryption key in the database.
 }
开发者ID:haomaro,项目名称:Calima,代码行数:27,代码来源:CFSesion.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, 'session_cache_limiter' => 'none'), $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'];
     session_set_cookie_params($lifetime, $path, $domain, $secure, $httpOnly);
     if (!is_null($this->options['session_cache_limiter'])) {
         session_cache_limiter($this->options['session_cache_limiter']);
     }
     if ($this->options['auto_start'] && !self::$sessionStarted) {
         session_start();
         self::$sessionStarted = true;
     }
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:44,代码来源:sfSessionStorage.class.php

示例6: init

 public function init($options = null)
 {
     $cookie_defaults = session_get_cookie_params();
     if (!isset($options['session_cookie_path']) && class_exists("waSystem")) {
         $options['session_cookie_path'] = waSystem::getInstance()->getRootUrl();
     }
     $options = array_merge(array('session_id' => null, 'auto_start' => true, 'session_cookie_lifetime' => $cookie_defaults['lifetime'], 'session_cookie_path' => $cookie_defaults['path'], 'session_cookie_domain' => $cookie_defaults['domain'], 'session_cookie_secure' => $cookie_defaults['secure'], 'session_cookie_httponly' => true, 'session_cache_limiter' => 'none'), $options);
     // initialize parent
     parent::init($options);
     if (isset($this->options['session_name'])) {
         session_name($this->options['session_name']);
     }
     if (!(bool) ini_get('session.use_cookies') && ($session_id = $this->options['session_id'])) {
         session_id($session_id);
     }
     $lifetime = $this->options['session_cookie_lifetime'];
     $path = $this->options['session_cookie_path'];
     $domain = $this->options['session_cookie_domain'];
     $secure = $this->options['session_cookie_secure'];
     $http_only = $this->options['session_cookie_httponly'];
     session_set_cookie_params($lifetime, $path, $domain, $secure, $http_only);
     if (null !== $this->options['session_cache_limiter']) {
         session_cache_limiter($this->options['session_cache_limiter']);
     }
     if ($this->options['auto_start']) {
         if (isset($_COOKIE[session_name()])) {
             $this->open();
         }
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:30,代码来源:waSessionStorage.class.php

示例7: ensure_session

function ensure_session()
{
    if (session_id() !== "") {
        return true;
    }
    if (!($sn = make_session_name(opt("sessionName")))) {
        return false;
    }
    // maybe upgrade from an old session name to this one
    if (!isset($_COOKIE[$sn]) && ($upgrade_sn = opt("sessionUpgrade")) && ($upgrade_sn = make_session_name($upgrade_sn)) && isset($_COOKIE[$upgrade_sn])) {
        session_id($_COOKIE[$upgrade_sn]);
        setcookie($upgrade_sn, "", time() - 3600, "/", opt("sessionUpgradeDomain", opt("sessionDomain", "")), opt("sessionSecure", false));
    }
    $secure = opt("sessionSecure");
    $domain = opt("sessionDomain");
    if ($secure !== null || $domain !== null) {
        $params = session_get_cookie_params();
        if ($secure !== null) {
            $params["secure"] = !!$secure;
        }
        if ($domain !== null) {
            $params["domain"] = $domain;
        }
        session_set_cookie_params($params["lifetime"], $params["path"], $params["domain"], $params["secure"]);
    }
    session_name($sn);
    session_cache_limiter("");
    if (isset($_COOKIE[$sn]) && !preg_match(';\\A[-a-zA-Z0-9,]{1,128}\\z;', $_COOKIE[$sn])) {
        error_log("unexpected session ID <" . $_COOKIE[$sn] . ">");
        unset($_COOKIE[$sn]);
    }
    session_start();
    return true;
}
开发者ID:kohler,项目名称:peteramati,代码行数:34,代码来源:redirect.php

示例8: __construct

 /**
  *
  * Constructor
  *
  * @param SegmentFactory $segment_factory A session segment factory.
  *
  * @param                CsrfTokenFactory A CSRF token factory.
  *
  * @param array          $cookies         An arry of cookies from the client, typically a
  *                                        copy of $_COOKIE.
  *
  */
 public function __construct(SegmentFactory $segment_factory, CsrfTokenFactory $csrf_token_factory, array $cookies = array())
 {
     $this->segment_factory = $segment_factory;
     $this->csrf_token_factory = $csrf_token_factory;
     $this->cookies = $cookies;
     $this->cookie_params = session_get_cookie_params();
 }
开发者ID:edrdesigner,项目名称:awf,代码行数:19,代码来源:Manager.php

示例9: destroyCookie

 /**
  *
  */
 public function destroyCookie()
 {
     if (ini_get("session.use_cookies")) {
         $params = session_get_cookie_params();
         setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
     }
 }
开发者ID:ramonztro,项目名称:lightwork-mvc,代码行数:10,代码来源:Session.php

示例10: user_logout

 /**
  * Logs out a user and resets the complete session
  * @author  Clemens John <clemens-john@gmx.de>
  * @return boolean true if the logout was successfull
  */
 public function user_logout()
 {
     if (!isset($_SESSION['user_id'])) {
         $messages[] = array("Sie können sich nicht ausloggen, wenn Sie nicht eingeloggt sind", 2);
         Message::setMessage($messages);
         return false;
     } else {
         //destroy current session
         //to correctly destroy a session look at http://php.net/manual/de/function.session-destroy.php
         $stmt = DB::getInstance()->prepare("UPDATE users SET session_id = ? WHERE id = ?");
         $stmt->execute(array('', $_SESSION['user_id']));
         //delete all Remember-Mes from the database (TODO: this could be improved by storing
         //the current session id along with the remember me and then delete only the remember me
         //coresponding to the current session.
         $user_remember_me_list = new UserRememberMeList($_SESSION['user_id']);
         $user_remember_me_list->delete();
         unset($_SESSION);
         unset($_COOKIE);
         setcookie("remember_me", "", time() - 60 * 60 * 24 * 14);
         setcookie(session_name(), '', time() - 3600, '/');
         if (ini_get("session.use_cookies")) {
             $params = session_get_cookie_params();
             setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
         }
         session_destroy();
         session_start();
         $messages[] = array("Sie wurden ausgeloggt und ihre Benutzersession wurde gelöscht!", 1);
         Message::setMessage($messages);
         return true;
     }
 }
开发者ID:wAmpIre,项目名称:netmon,代码行数:36,代码来源:login.class.php

示例11: indexAction

 public function indexAction()
 {
     $this->_helper->layout()->disableLayout();
     if (isset($_COOKIE['icingaweb2-session'])) {
         $last = (int) $_COOKIE['icingaweb2-session'];
     } else {
         $last = 0;
     }
     $now = time();
     if ($last + 600 < $now) {
         Session::getSession()->write();
         $params = session_get_cookie_params();
         setcookie('icingaweb2-session', $now, null, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
         $_COOKIE['icingaweb2-session'] = $now;
     }
     $announcementCookie = new AnnouncementCookie();
     $announcementRepo = new AnnouncementIniRepository();
     if ($announcementCookie->getEtag() !== $announcementRepo->getEtag()) {
         $announcementCookie->setEtag($announcementRepo->getEtag())->setNextActive($announcementRepo->findNextActive());
         $this->getResponse()->setCookie($announcementCookie);
         $this->getResponse()->setHeader('X-Icinga-Announcements', 'refresh', true);
     } else {
         $nextActive = $announcementCookie->getNextActive();
         if ($nextActive && $nextActive <= $now) {
             $announcementCookie->setNextActive($announcementRepo->findNextActive());
             $this->getResponse()->setCookie($announcementCookie);
             $this->getResponse()->setHeader('X-Icinga-Announcements', 'refresh', true);
         }
     }
     $this->getResponse()->setHeader('X-Icinga-Container', 'ignore', true);
 }
开发者ID:0svald,项目名称:icingaweb2,代码行数:31,代码来源:ApplicationStateController.php

示例12: __construct

 /**
  * @param array $config
  */
 public function __construct(array $config = [])
 {
     // make sure we've got all config elements for this driver
     $config['native'] = array_merge($this->defaults, isset($config['native']) ? $config['native'] : array());
     // call the parent to process the global config
     parent::__construct($config);
     // get default the cookie params
     $params = session_get_cookie_params();
     // update them with any config passed
     if (isset($config['cookie_domain'])) {
         $params['domain'] = $config['cookie_domain'];
     }
     if (isset($config['cookie_path'])) {
         $params['path'] = $config['cookie_path'];
     }
     if (isset($config['cookie_secure']) and $config['cookie_secure']) {
         $params['secure'] = true;
     }
     if (isset($config['cookie_http_only']) and $config['cookie_http_only']) {
         $params['httponly'] = true;
     }
     if (isset($config['expire_on_close']) and $config['expire_on_close']) {
         $params['lifetime'] = 0;
     }
     session_set_cookie_params($this->expiration, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
     // store the defined name
     if (isset($config['native']['cookie_name'])) {
         $this->name = $config['native']['cookie_name'];
     }
 }
开发者ID:fuelphp,项目名称:session,代码行数:33,代码来源:Native.php

示例13: setCookie

 protected function setCookie()
 {
     $data = json_encode($this->_data);
     $sig = $this->_sig($data . $this->_getCookieDomain(), $this->getOption('secret'));
     $params = session_get_cookie_params();
     Pix_HttpResponse::setcookie($this->_getCookieKey(), $sig . '|' . $data, $this->_getTimeout() ? time() + $this->_getTimeout() : null, $this->_getCookiePath(), $this->_getCookieDomain());
 }
开发者ID:pixnet,项目名称:pixframework,代码行数:7,代码来源:Cookie.php

示例14: index

 /**
  * Index Page for this controller.
  */
 public function index()
 {
     // Initialize the session.
     if ($this->is_session_started() === FALSE) {
         session_start();
     }
     // Unset all of the session variables.
     $_SESSION = array();
     // If it's desired to kill the session, also delete the session cookie.
     // Note: This will destroy the session, and not just the session data!
     if (ini_get("session.use_cookies")) {
         $params = session_get_cookie_params();
         setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
     }
     // Finally, destroy the session.
     if ($this->is_session_started() === TRUE) {
         session_unset();
         session_destroy();
     }
     // $session_data = $this->session->all_userdata();
     //
     // foreach($session_data as $key => $value) {
     //   $this->session->unset_userdata($key);
     // }
     //
     // $this->session->sess_destroy();
     redirect("/", 302);
 }
开发者ID:depannagelafrance,项目名称:towing_web,代码行数:31,代码来源:Index.php

示例15: sec_session_start

function sec_session_start()
{
    $session_name = 'examen_session_id';
    // Asignamos un nombre de sesión.
    $secure = false;
    // Mejor en config.php Lo ideal sería true para trabajar con https.
    $httponly = true;
    // Obliga a la sesión a utilizar solo cookies.
    // Habilitar este ajuste previene de ataques que implican pasar el id de sesión en la URL.
    if (ini_set('session.use_only_cookies', 1) === FALSE) {
        $action = "error";
        $error = "No puedo iniciar una sesion segura (ini_set)";
    }
    // Obtener los parámetros de la cookie de sesión
    $cookies = session_get_cookie_params();
    session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly);
    //Marca la cookie como accesible sólo a través del protocolo HTTP.
    // Esto siginifica que la cookie no será accesible por lenguajes de script,
    // tales como JavaScript.
    // Este ajuste puede ayudar de manera efectiva a reducir robos de
    // indentidad a través de ataques.
    // Incia la sesión PHP
    session_name($session_name);
    session_start();
    // Actualiza el id de sesión actual con uno generado más reciente.
    // Ayuda a evitar ataques de fijación de sesión.
    session_regenerate_id(true);
}
开发者ID:Lybert,项目名称:GBD,代码行数:28,代码来源:functions.php


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