本文整理汇总了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();
}
示例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.
}
}
示例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;
}
}
}
}
}
示例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();
}
}
示例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;
}
示例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();
}
示例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();
}
}
示例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%";
}
示例9: generateId
private static function generateId()
{
@session_start();
$id = session_id();
session_destroy();
return $id;
}
示例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']);
}
示例11: setFlash
function setFlash($type, $message)
{
if (!isSessionStarted()) {
session_start();
}
$_SESSION['flash'][$type] = $message;
}
示例12: __construct
/**
* コンストラクタ
*/
public function __construct()
{
if (!self::$session_started) {
session_start();
self::$session_started = true;
}
}
示例13: __construct
function __construct()
{
parent::__construct();
session_start();
$this->load->model('user_model');
$this->load->helper(array('form'));
}
示例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');
}
示例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);
}