當前位置: 首頁>>代碼示例>>PHP>>正文


PHP session_start函數代碼示例

本文整理匯總了PHP中session_start函數的典型用法代碼示例。如果您正苦於以下問題:PHP session_start函數的具體用法?PHP session_start怎麽用?PHP session_start使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了session_start函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: start

 public static function start($lifetime = 0, $path = '/', $domain = NULL)
 {
     if (!self::$_initialized) {
         if (!is_object(Symphony::Database()) || !Symphony::Database()->connected()) {
             return false;
         }
         $cache = Cache::instance()->read('_session_config');
         if (is_null($cache) || $cache === false) {
             self::create();
             Cache::instance()->write('_session_config', true);
         }
         if (!session_id()) {
             ini_set('session.save_handler', 'user');
             ini_set('session.gc_maxlifetime', $lifetime);
             ini_set('session.gc_probability', '1');
             ini_set('session.gc_divisor', '3');
         }
         session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc'));
         session_set_cookie_params($lifetime, $path, $domain ? $domain : self::getDomain(), false, false);
         if (strlen(session_id()) == 0) {
             if (headers_sent()) {
                 throw new Exception('Headers already sent. Cannot start session.');
             }
             session_start();
         }
         self::$_initialized = true;
     }
     return session_id();
 }
開發者ID:brendo,項目名稱:symphony-3,代碼行數:29,代碼來源:class.session.php

示例2: 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

示例3: permisos

function permisos($rol, $ruta)
{
    session_start();
    //Si no hay una sesion iniciada, redirige al login
    if (!$_SESSION) {
        header('Location:' . $ruta . 'vistas/login.php');
    } else {
        //Si no existe la variable de sesion del usuario logueado, redirige al login
        if (!isset($_SESSION["rol"])) {
            header('Location:' . $ruta . 'vistas/login.php');
        } else {
            if ($_SESSION["rol"] != $rol && $_SESSION["login_usuario"] != 'test') {
                header('location:' . $ruta . 'vistas/menu.php');
            } else {
                include_once '' . $ruta . 'vistas/headers.php';
                //Escoge el idioma por defecto si no tiene uno el usuario
                if (!$_SESSION["idioma"]) {
                    $includeIdioma = $ruta . "modelo/esp.php";
                    return $includeIdioma;
                } else {
                    $includeIdioma = $ruta . "modelo/" . $_SESSION['idioma'] . ".php";
                    return $includeIdioma;
                }
            }
        }
    }
}
開發者ID:developergate,項目名稱:ET1v2,代碼行數:27,代碼來源:ctrl_permisos.php

示例4: 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

示例5: startSession

 /**
  * Sets the time against which the session is measured. This function also
  * sets the cash_session_id internally as a mechanism for tracking analytics
  * against a consistent id, regardless of PHP session id.
  *
  * @return boolean
  */
 protected function startSession()
 {
     // begin PHP session
     if (!defined('STDIN')) {
         // no session for CLI, suckers
         @session_cache_limiter('nocache');
         $session_length = 3600;
         @ini_set("session.gc_maxlifetime", $session_length);
         @session_start();
     }
     $this->cash_session_timeout = ini_get("session.gc_maxlifetime");
     if (!isset($_SESSION['cash_session_id'])) {
         $modifier_array = array('deedee', 'johnny', 'joey', 'tommy', 'marky');
         $_SESSION['cash_session_id'] = $modifier_array[array_rand($modifier_array)] . '_' . rand(1000, 9999) . substr((string) time(), 4);
     }
     if (isset($_SESSION['cash_last_request_time'])) {
         if ($_SESSION['cash_last_request_time'] + $this->cash_session_timeout < time()) {
             $this->resetSession();
         }
     }
     $_SESSION['cash_last_request_time'] = time();
     if (!isset($GLOBALS['cash_script_store'])) {
         $GLOBALS['cash_script_store'] = array();
     }
     return true;
 }
開發者ID:nodots,項目名稱:DIY,代碼行數:33,代碼來源:CASHData.php

示例6: __construct

 /**
  * Constructor. Starts PHP session handling in our own private store
  *
  * Side-effect: might set a cookie, so must be called before any other output.
  */
 public function __construct()
 {
     $this->typo3tempPath = PATH_site . 'typo3temp/';
     // Start our PHP session early so that hasSession() works
     $sessionSavePath = $this->getSessionSavePath();
     // Register our "save" session handler
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
     session_save_path($sessionSavePath);
     session_name($this->cookieName);
     ini_set('session.cookie_path', GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'));
     // Always call the garbage collector to clean up stale session files
     ini_set('session.gc_probability', 100);
     ini_set('session.gc_divisor', 100);
     ini_set('session.gc_maxlifetime', $this->expireTimeInMinutes * 2 * 60);
     if (\TYPO3\CMS\Core\Utility\PhpOptionsUtility::isSessionAutoStartEnabled()) {
         $sessionCreationError = 'Error: session.auto-start is enabled.<br />';
         $sessionCreationError .= 'The PHP option session.auto-start is enabled. Disable this option in php.ini or .htaccess:<br />';
         $sessionCreationError .= '<pre>php_value session.auto_start Off</pre>';
         throw new \TYPO3\CMS\Install\Exception($sessionCreationError, 1294587485);
     } elseif (defined('SID')) {
         $sessionCreationError = 'Session already started by session_start().<br />';
         $sessionCreationError .= 'Make sure no installed extension is starting a session in its ext_localconf.php or ext_tables.php.';
         throw new \TYPO3\CMS\Install\Exception($sessionCreationError, 1294587486);
     }
     session_start();
 }
開發者ID:rickymathew,項目名稱:TYPO3.CMS,代碼行數:31,代碼來源:SessionService.php

示例7: signIn

 public function signIn($userName, $passwordMd5)
 {
     $tempconnect = $this->connector;
     $sql = "SELECT * FROM users WHERE name=? and password=?";
     $stmt = $tempconnect->prepare($sql);
     $stmt->bind_param('ss', $userName, $passwordMd5);
     $stmt->execute();
     //direk deðerleri döndürür
     /*while($stmt->fetch())
       {
           echo $userName. " ". $passwordMd5;
           echo "<br>";
       }*/
     //count döndürür
     while ($satir = $stmt->fetch()) {
         $this->conservative = $satir;
     }
     if ($this->conservative) {
         echo "basarili";
         session_start();
         $_SESSION["login"] = "login";
         $stmt->close();
         echo "<script>window.location.replace('userProfile.php');</script>";
     } else {
         echo "basarisiz";
         $stmt->close();
     }
 }
開發者ID:aslanahmet,項目名稱:test2,代碼行數:28,代碼來源:app.php

示例8: Gerar

 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     $this->titulo = "Software - Detalhe";
     $this->addBanner("http://ieducar.dccobra.com.br/intranet/imagens/nvp_top_intranet.jpg", "http://ieducar.dccobra.com.br/intranet/imagens/nvp_vert_intranet.jpg", "Intranet");
     $this->cod_software = $_GET["cod_software"];
     $tmp_obj = new clsPmicontrolesisSoftware($this->cod_software);
     $registro = $tmp_obj->detalhe();
     if (!$registro) {
         header("location: controlesis_software_lst.php");
         die;
     }
     if ($registro["cod_software"]) {
         $this->addDetalhe(array("Software", "{$registro["cod_software"]}"));
     }
     if ($registro["nm_software"]) {
         $this->addDetalhe(array("Nome Software", "{$registro["nm_software"]}"));
     }
     $this->url_novo = "controlesis_software_cad.php";
     $this->url_editar = "controlesis_software_cad.php?cod_software={$registro["cod_software"]}";
     $this->url_cancelar = "controlesis_software_lst.php";
     $this->largura = "100%";
 }
開發者ID:eritter-ti,項目名稱:ieducar,代碼行數:25,代碼來源:controlesis_software_det.php

示例9: generateId

 private static function generateId()
 {
     @session_start();
     $id = session_id();
     session_destroy();
     return $id;
 }
開發者ID:unkerror,項目名稱:Budabot,代碼行數:7,代碼來源:SessionStorage.php

示例10: regenerateSession

function regenerateSession($reload = false)
{
    // This token is used by forms to prevent cross site forgery attempts
    if (!isset($_SESSION['nonce']) || $reload) {
        $_SESSION['nonce'] = md5(microtime(true));
    }
    if (!isset($_SESSION['IPaddress']) || $reload) {
        $_SESSION['IPaddress'] = $_SERVER['REMOTE_ADDR'];
    }
    if (!isset($_SESSION['userAgent']) || $reload) {
        $_SESSION['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
    }
    //$_SESSION['user_id'] = $this->user->getId();
    // Set current session to expire in 1 minute
    $_SESSION['OBSOLETE'] = true;
    $_SESSION['EXPIRES'] = time() + 60;
    // Create new session without destroying the old one
    session_regenerate_id(false);
    // Grab current session ID and close both sessions to allow other scripts to use them
    $newSession = session_id();
    session_write_close();
    // Set session ID to the new one, and start it back up again
    session_id($newSession);
    session_start();
    // Don't want this one to expire
    unset($_SESSION['OBSOLETE']);
    unset($_SESSION['EXPIRES']);
}
開發者ID:pombredanne,項目名稱:LLicenseChecker,代碼行數:28,代碼來源:functions.php

示例11: setFlash

function setFlash($type, $message)
{
    if (!isSessionStarted()) {
        session_start();
    }
    $_SESSION['flash'][$type] = $message;
}
開發者ID:RoroL,項目名稱:onmangequoicemidi,代碼行數:7,代碼來源:fonctions.php

示例12: __construct

 /**
  * コンストラクタ
  */
 public function __construct()
 {
     if (!self::$session_started) {
         session_start();
         self::$session_started = true;
     }
 }
開發者ID:hironomiu,項目名稱:web-performance-tuning,代碼行數:10,代碼來源:Session.php

示例13: __construct

 function __construct()
 {
     parent::__construct();
     session_start();
     $this->load->model('user_model');
     $this->load->helper(array('form'));
 }
開發者ID:sauhardad,項目名稱:pizzasys,代碼行數:7,代碼來源:user.php

示例14: initContent

 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     $this->display_column_left = false;
     $this->display_column_right = false;
     parent::initContent();
     $cart = $this->context->cart;
     $client = $this->context->customer;
     $invoice_address = new Address((int) $cart->id_address_invoice);
     $state = new State((int) $invoice_address->id_state);
     $arreglo_meses = array();
     for ($i = 1; $i <= 12; $i++) {
         $arreglo_meses[] = sprintf("%02s", $i);
     }
     $arreglo_anyos = array();
     $anyo_actual = date("Y", time());
     for ($i = 0; $i < 12; $i++) {
         $arreglo_anyos[] = substr($anyo_actual + $i, -2);
     }
     session_start();
     $arreglo_errores = array();
     if (is_array($_SESSION['errores'])) {
         foreach ($_SESSION['errores'] as $key => $value) {
             $arreglo_errores[$key] = $value;
         }
     }
     unset($_SESSION['errores']);
     $this->context->smarty->assign(array('nbProducts' => $cart->nbProducts(), 'monto' => $cart->getOrderTotal(true, Cart::BOTH), 'this_path' => $this->module->getPathUri(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/', 'nombre' => $client->firstname, 'apellidos' => $client->lastname, 'cp' => $invoice_address->postcode, 'monto' => $cart->getOrderTotal(true, Cart::BOTH), 'email' => $client->email, 'telefono' => $invoice_address->phone, 'celular' => $invoice_address->phone_mobile, 'calleyNumero' => $invoice_address->address1, 'colonia' => '', 'municipio' => $invoice_address->city, 'estado' => $state->name, 'pais' => $invoice_address->country, 'anyos' => $arreglo_anyos, 'meses' => $arreglo_meses, 'errores' => $arreglo_errores));
     $this->setTemplate('payment_execution.tpl');
 }
開發者ID:javolero,項目名稱:PrestaShopPlugin,代碼行數:32,代碼來源:payment.php

示例15: __construct

 /**
  * Identical to the parent constructor, except that
  * we start a PHP session to store the user ID and
  * access token if during the course of execution
  * we discover them.
  *
  * @param Array $config the application configuration.
  * @see BaseFacebook::__construct in facebook.php
  */
 public function __construct($config)
 {
     if (!session_id()) {
         session_start();
     }
     parent::__construct($config);
 }
開發者ID:VLabsInc,項目名稱:WordPressPlatforms,代碼行數:16,代碼來源:facebook.php


注:本文中的session_start函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。