本文整理汇总了PHP中session_id函数的典型用法代码示例。如果您正苦于以下问题:PHP session_id函数的具体用法?PHP session_id怎么用?PHP session_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了session_id函数的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: tracker
function tracker()
{
$session_id = session_id();
$ip = $_SERVER['REMOTE_ADDR'];
$referrer = isset($_SERVER['HTTP_REFERRER']) ? $_SERVER['HTTP_REFERRER'] : '';
$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$created = time();
// ERROR HERE..
$date = date("Y-m-d");
if (!$_SESSION['online']) {
$query = "INSERT INTO people_online\tVALUES('" . session_id() . "', '{$date}', 'n', '{$ip}', '{$referrer}', '{$user_agent}')";
if (!$this->query($query)) {
$this->error();
}
// session_register('online');
$_SESSION['online'] = true;
//echo "Session ID (online 1): ".session_id();
}
#} else {
if (isset($_SESSION['userID'])) {
//echo "<br>Session ID (userID) for users: ".session_id();
$query = "INSERT INTO people_online\tVALUES('" . session_id() . "', '{$date}', 'y', '{$ip}', '{$referrer}', '{$user_agent}')";
if (!$this->query($query)) {
$this->error();
}
}
#}
}
示例4: __construct
/**
* Constructor
*
* Instantiate the CSRF form element object.
*
* @param string $name
* @param string $value
* @param int $expire
* @param string $indent
* @return \Pop\Form\Element\Csrf
*/
public function __construct($name, $value = null, $expire = 300, $indent = null)
{
// Start a session.
if (session_id() == '') {
session_start();
}
// If token does not exist, create one
if (!isset($_SESSION['pop_csrf'])) {
$this->token = array('value' => sha1(rand(10000, getrandmax()) . $value), 'expire' => (int) $expire, 'start' => time());
$_SESSION['pop_csrf'] = serialize($this->token);
// Else, retrieve existing token
} else {
$this->token = unserialize($_SESSION['pop_csrf']);
// Check to see if the token has expired
if ($this->token['expire'] > 0) {
if ($this->token['expire'] + $this->token['start'] < time()) {
$this->token = array('value' => sha1(rand(10000, getrandmax()) . $value), 'expire' => (int) $expire, 'start' => time());
$_SESSION['pop_csrf'] = serialize($this->token);
}
}
}
parent::__construct('hidden', $name, $this->token['value'], null, $indent);
$this->setRequired(true);
$this->setValidator();
}
示例5: Factory
public static function Factory(&$source, $conf_file = NULL, $conf_section = NULL, $strict = TRUE)
{
if (!is_array($source)) {
user_error('$source ' . $source . ' is not an array', E_USER_NOTICE);
}
$cage = new Inspekt_Cage_Session();
$cage->_setSource($source);
$cage->_parseAndApplyAutoFilters($conf_file);
if (ini_get('session.use_cookies') || ini_get('session.use_only_cookies')) {
if (isset($_COOKIE) && isset($_COOKIE[session_name()])) {
session_id($_COOKIE[session_name()]);
} elseif ($cookie = Inspekt::makeSessionCage()) {
session_id($cookie->getAlnum(session_name()));
}
} else {
// we're using session ids passed via GET
if (isset($_GET) && isset($_GET[session_name()])) {
session_id($_GET[session_name()]);
} elseif ($cookie = Inspekt::makeSessionCage()) {
session_id($cookie->getAlnum(session_name()));
}
}
if ($strict) {
$source = NULL;
}
return $cage;
register_shutdown_function();
register_shutdown_function(array($this, '_repopulateSession'));
}
示例6: startSession
/**
* Starts the session if it does not exist.
*
* @return void
*/
protected function startSession()
{
// Check that the session hasn't already been started
if (session_id() == '' && !headers_sent()) {
session_start();
}
}
示例7: __construct
/**
* Constructor of SessionContext, init session and set session file path
*
* @return void
**/
function __construct()
{
if (defined('SESSION_PATH')) {
session_save_path(SESSION_PATH);
}
if (is_writable(session_save_path())) {
if (!defined('CLI') || CLI == 0) {
session_start();
}
} else {
// we cannot write in the session save path; aborting
die("Unable to write in the session save path [" . session_save_path() . "]");
}
// retrieve objects data
if (defined('SESSION_PATH')) {
$this->_sessObjFileName = SESSION_PATH . "/" . session_id() . "_obj";
}
// record access time
$curTime = time();
if (isset($_SESSION["LastAccessTime"])) {
$this->_lastAccessTime = $_SESSION["LastAccessTime"];
} else {
$this->_lastAccessTime = $curTime;
}
$_SESSION["LastAccessTime"] = $curTime;
// see if timeout
$this->_timeOut = false;
if (TIMEOUT > 0 && $curTime - $this->_lastAccessTime > TIMEOUT) {
$this->_timeOut = true;
}
}
示例8: oauth_callback
/**
* Receives oauth_verifier, requests for access_token and redirect to callback
*/
public function oauth_callback()
{
if (!session_id()) {
session_start();
}
$session = $_SESSION['_opauth_twitter'];
unset($_SESSION['_opauth_twitter']);
if (!empty($_REQUEST['oauth_token']) && $_REQUEST['oauth_token'] == $session['oauth_token']) {
$this->tmhOAuth->config['user_token'] = $session['oauth_token'];
$this->tmhOAuth->config['user_secret'] = $session['oauth_token_secret'];
$params = array('oauth_verifier' => $_REQUEST['oauth_verifier']);
$results = $this->_request('POST', $this->strategy['access_token_url'], $params);
if ($results !== false && !empty($results['oauth_token']) && !empty($results['oauth_token_secret'])) {
$credentials = $this->_verify_credentials($results['oauth_token'], $results['oauth_token_secret']);
// print_r($credentials);exit;
if (!empty($credentials['id'])) {
// Create a dummy email for registration purpose
$email = $credentials['screen_name'] . '@twitter.com';
$this->auth = array('uid' => $credentials['id'], 'info' => array('name' => $credentials['name'], 'nickname' => $credentials['screen_name'], 'email' => $email, 'urls' => array('twitter' => str_replace('{screen_name}', $credentials['screen_name'], $this->strategy['twitter_profile_url']))), 'credentials' => array('token' => $results['oauth_token'], 'secret' => $results['oauth_token_secret']), 'raw' => $credentials);
$this->mapProfile($credentials, 'location', 'info.location');
$this->mapProfile($credentials, 'description', 'info.description');
$this->mapProfile($credentials, 'profile_image_url', 'info.image');
$this->mapProfile($credentials, 'url', 'info.urls.website');
$this->callback();
}
}
} else {
$error = array('code' => 'access_denied', 'message' => 'User denied access.', 'raw' => $_GET);
$this->errorCallback($error);
}
}
示例9: initialize
public function initialize($options = null)
{
if (session_id() != '') {
self::$sessionStarted = true;
}
parent::initialize($options);
}
示例10: call
public function call()
{
$that = $this;
if (!$this->app->config('session.preventSession') && session_id() === '') {
throw new \Exception('NotificationMiddleware needs \\Bono\\Middleware\\SessionMiddleware or php native session');
}
$this->app->hook('notification.error', function ($options) use($that) {
$that->notify('error', $options);
});
$this->app->hook('notification.info', function ($options) use($that) {
$that->notify('info', $options);
});
$this->app->filter('notification.show', function ($options = null) use($that) {
return $that->show($options);
});
$this->app->filter('notification.message', function ($context) use($that) {
$errors = $that->query(array('level' => 'error', 'context' => $context));
if (!empty($errors)) {
return $errors[0]['message'];
}
});
$this->app->notification = $this;
$this->populate();
try {
$this->next->call();
} catch (INotifiedException $e) {
h('notification.error', $e);
}
$this->save();
}
示例11: getMessage
function getMessage()
{
if (!session_id() && !headers_sent()) {
session_start();
}
$mess = null;
switch ($_SESSION['apMess'][$this->getMessSessionName()]) {
case 'delete_ok':
$mess = 'File delete';
break;
case 'delete_fail':
$mess = 'Error! Record is not removed';
break;
case 'update_ok':
$mess = 'The information has been updated successfully';
break;
case 'update_fail':
$mess = 'Error update';
break;
case 'add_ok':
$mess = 'File add';
break;
case 'add_fail':
$mess = 'When adding an entry error has occurred';
break;
}
$_SESSION['apMess'] = array();
return $mess;
}
示例12: setuserpdffont
protected function setuserpdffont()
{
if (session_id() == '') {
session_start();
}
if (isset($_SESSION['PDFLanguage'])) {
$UserPdfLang = $_SESSION['PDFLanguage'];
switch ($UserPdfLang) {
case 0:
$UserPdfFont = 'times';
break;
case 1:
$UserPdfFont = 'javierjp';
break;
case 2:
$UserPdfFont = 'javiergb';
break;
case 3:
$UserPdfFont = 'freeserif';
break;
}
} else {
$UserPdfFont = 'helvetica';
}
$this->SetFont($UserPdfFont, '', 11);
// SetFont($family, $style='', $size=0, $fontfile='')
}
示例13: run
public function run()
{
if (empty($this->config['action'])) {
throw new CException('EAjaxUpload: param "action" cannot be empty.');
}
if (empty($this->config['allowedExtensions'])) {
throw new CException('EAjaxUpload: param "allowedExtensions" cannot be empty.');
}
if (empty($this->config['sizeLimit'])) {
throw new CException('EAjaxUpload: param "sizeLimit" cannot be empty.');
}
unset($this->config['element']);
echo '<div id="' . $this->id . '"><noscript><p>Habilite Jva Script en este navegador para usar esta funcion .</p></noscript></div>';
$assets = dirname(__FILE__) . '/assets';
$baseUrl = Yii::app()->assetManager->publish($assets);
Yii::app()->clientScript->registerScriptFile($baseUrl . '/fileuploader.js', CClientScript::POS_HEAD);
$this->css = !empty($this->css) ? $this->css : $baseUrl . '/fileuploader.css';
Yii::app()->clientScript->registerCssFile($this->css);
$postParams = array('PHPSESSID' => session_id(), 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken);
if (isset($this->postParams)) {
$postParams = array_merge($postParams, $this->postParams);
}
$config = array('element' => 'js:document.getElementById("' . $this->id . '")', 'debug' => false, 'multiple' => false);
$config = array_merge($config, $this->config);
$config['params'] = $postParams;
$config = CJavaScript::encode($config);
Yii::app()->getClientScript()->registerScript("FileUploader_" . $this->id, "var FileUploader_" . $this->id . " = new qq.FileUploader({$config}); ", CClientScript::POS_LOAD);
}
示例14: openSession
/**
* Open PHP SESSION using amazon provided sessionId, for storing data about the session.
* Session cookie won't be sent.
*/
public function openSession()
{
ini_set('session.use_cookies', 0);
# disable session cookies
session_id($this->parseSessionId($this->sessionId));
return session_start();
}
示例15: actionAuthorizeView
/**
* logout
*/
public function actionAuthorizeView($appkey, $clientid)
{
$sessionid = session_id();
$map = $this->getRestMap();
/**
* @var AccessToken $token
*/
try {
Assert::hasText($appkey, "appkey传递参数为空!");
Assert::hasText($clientid, "clientid传递参数为空!");
$token = BCacheHelper::getToken($clientid, 'model');
Assert::hasText($token, "token 查询结果为空!");
//data
$map["appkey"] = $token->appkey;
$map["clientid"] = $token->clientid;
$map["tokenid"] = $token->tokenid;
$map[AjaxStatus::PROPERTY_MESSAGES] = "操作成功";
$map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_SUCCESSFUL;
$map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_OK;
} catch (IllegalArgumentException $e) {
$map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_FAILED;
$map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_503;
$map[AjaxStatus::PROPERTY_MESSAGES] = $e->getMessage();
} catch (Exception $e) {
$map[AjaxStatus::PROPERTY_STATUS] = AjaxStatus::STATUS_FAILED;
$map[AjaxStatus::PROPERTY_CODE] = AjaxStatus::CODE_503;
$map[AjaxStatus::PROPERTY_MESSAGES] = $e->getMessage();
}
echo SnapshotHelper::encodeArray($map);
}