本文整理汇总了PHP中session_save_path函数的典型用法代码示例。如果您正苦于以下问题:PHP session_save_path函数的具体用法?PHP session_save_path怎么用?PHP session_save_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了session_save_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
}
示例2: setup
public static function setup()
{
$session_conf = (array) \Gini\Config::get('system.session');
$cookie_params = (array) $session_conf['cookie'];
$session_name = $session_conf['name'] ?: 'gini-session';
$host_hash = sha1($cookie_params['domain'] ?: $_SERVER['HTTP_HOST']);
ini_set('session.name', $session_name . '_' . $host_hash);
if ($session_conf['save_handler']) {
self::$_handlerName = $session_conf['save_handler'];
// save_handler = internal/files
if (0 == strncmp(self::$_handlerName, 'internal/', 9)) {
ini_set('session.save_handler', substr(self::$_handlerName, 9));
} else {
// save_handler = Database
$class = '\\Gini\\Session\\' . self::$_handlerName;
if (class_exists($class)) {
self::$_handler = \Gini\IoC::construct($class);
session_set_save_handler(self::$_handler, false);
}
}
}
if ($session_conf['save_path']) {
session_save_path($session_conf['save_path']);
}
if ($session_conf['gc_maxlifetime']) {
ini_set('session.gc_maxlifetime', $session_conf['gc_maxlifetime']);
}
if (isset($_POST['gini-session'])) {
session_id($_POST['gini-session']);
} elseif (isset($_SERVER['HTTP_X_GINI_SESSION'])) {
session_id($_SERVER['HTTP_X_GINI_SESSION']);
}
session_set_cookie_params($cookie_params['lifetime'], $cookie_params['path'], $cookie_params['domain']);
self::open();
}
示例3: __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;
}
}
示例4: __construct
protected function __construct()
{
/* Call the parent constructor in case it should become
* necessary in the future.
*/
parent::__construct();
/* Initialize the php session handling.
*
* If session_id() returns a blank string, then we need
* to call session start. Otherwise the session is already
* started, and we should avoid calling session_start().
*/
if (session_id() === '') {
$config = SimpleSAML_Configuration::getInstance();
$params = $this->getCookieParams();
$version = explode('.', PHP_VERSION);
if ((int) $version[0] === 5 && (int) $version[1] < 2) {
session_set_cookie_params($params['lifetime'], $params['path'], $params['domain'], $params['secure']);
} else {
session_set_cookie_params($params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']);
}
$this->cookie_name = $config->getString('session.phpsession.cookiename', NULL);
if (!empty($this->cookie_name)) {
session_name($this->cookie_name);
} else {
$this->cookie_name = session_name();
}
$savepath = $config->getString('session.phpsession.savepath', NULL);
if (!empty($savepath)) {
session_save_path($savepath);
}
}
}
示例5: run
function run($config)
{
try {
//session设置,控制访问
if (isset($config['session']) && !empty($config['session'])) {
if (is_string($config['session'])) {
session_save_path(__DIR__ . '/' . $config['session']);
}
if (!isset($_SESSION)) {
session_start();
}
if (!isset($_SESSION['admin'])) {
throw new Exception('你没有文件管理权限.');
}
}
if (!file_exists('YesFinder.class.php')) {
throw new Exception('主文件YesFinder.class.php丢失了.');
}
require 'YesFinder.class.php';
$app = new YesFinder($config);
if (!method_exists($app, $this->action)) {
throw new Exception("请求无效," . $this->action . " 不存在");
}
$data = call_user_func_array(array($app, $this->action), $this->params);
} catch (Exception $e) {
$data['error'] = $e->getMessage();
}
$this->output($data);
}
示例6: open
/**
* Open a session
*
* @access public
* @param string $base_path Cookie path
* @param string $save_path Custom session save path
*/
public function open($base_path = '/', $save_path = '')
{
if ($save_path !== '') {
session_save_path($save_path);
}
// HttpOnly and secure flags for session cookie
session_set_cookie_params(self::SESSION_LIFETIME, $base_path ?: '/', null, Tool::isHTTPS(), true);
// Avoid session id in the URL
ini_set('session.use_only_cookies', '1');
// Ensure session ID integrity
ini_set('session.entropy_file', '/dev/urandom');
ini_set('session.entropy_length', '32');
ini_set('session.hash_bits_per_character', 6);
// If session was autostarted with session.auto_start = 1 in php.ini destroy it, otherwise we cannot login
if (isset($_SESSION)) {
session_destroy();
}
// Custom session name
session_name('__S');
session_start();
// Regenerate the session id to avoid session fixation issue
if (empty($_SESSION['__validated'])) {
session_regenerate_id(true);
$_SESSION['__validated'] = 1;
}
}
示例7: __construct
public function __construct($config = null)
{
if (!isset($config['savePath'])) {
$config['savePath'] = session_save_path();
}
$this->_config = $config;
}
示例8: session_start_session
function session_start_session()
{
global $cfg;
session_save_path($cfg['SESSION_SAVE_PATH']);
session_name("UAPORTAL");
session_start();
}
示例9: doTest
function doTest()
{
$handler = ini_get("session.save_handler");
if ($handler != "files") {
$this->testedParams["Session Save Path"] = "Handler is not file based";
return TRUE;
}
$tmpDir = session_save_path();
$this->testedParams["Session Save Path"] = $tmpDir;
if ($tmpDir != "") {
$this->testedParams["Session Save Path Writeable"] = @is_writable($tmpDir);
if (!$this->testedParams["Session Save Path Writeable"]) {
$this->failedLevel = "error";
$this->failedInfo = "The temporary folder used by PHP to save the session data is either incorrect or not writeable! Please check : " . session_save_path();
$this->failedInfo .= "<p class='suggestion'><b>Suggestion</b> : create your own temporary folder for sessions and set the session.save_path parameter in the conf/bootstrap_conf.php</p>";
return FALSE;
}
} else {
$this->failedLevel = "warning";
$this->failedInfo = "Warning, it seems that your temporary folder used to save session data is not set. If you are encountering troubles with logging and sessions, please check session.save_path in your php.ini. Otherwise you can ignore this.";
return FALSE;
}
$this->failedLevel = "info";
return FALSE;
}
示例10: __construct
public function __construct($output = true)
{
ini_set('date.timezone', 'GMT');
$this->initClasses();
session_save_path($this->config->get('core.session'));
session_start();
$this->loadUser();
if ($output) {
$in_redirect_endpoint = false;
$redirect_endpoints = ['preregister', 'banned', 'account/terms', 'account/settings', 'account/login', 'account/logout'];
foreach ($redirect_endpoints as $endpoint) {
if (strpos($_SERVER['REQUEST_URI'], $endpoint) !== false) {
$in_redirect_endpoint = true;
}
}
$this->logger->log($_SERVER['REQUEST_URI'], 'DEBUG');
if ($this->config->get('mode') == 'preregistration' && !$in_redirect_endpoint) {
$this->output->redirect('/preregister');
}
if ($this->user->isLoggedIn() && $this->user->isRank('Banned') && !$in_redirect_endpoint) {
$this->output->redirect('/banned');
} elseif ($this->user->isLoggedIn() and $this->user->tos_agree == 0 && !$in_redirect_endpoint) {
$this->output->redirect('/account/terms');
} elseif ($this->user->isLoggedIn() && empty($this->user->trade_url) && !$in_redirect_endpoint) {
$this->output->redirect('/account/settings');
}
$this->router->resolve();
}
}
示例11: SetID
/**
* set session ID
*
* @param $sessionid
*
* @return mixed
*/
public static function SetID($sessionid)
{
$file = session_save_path() . "/sess_" . $sessionid;
if (file_exists($file)) {
session_id($sessionid);
}
}
示例12: initializeCAS
private function initializeCAS()
{
$casClient = new \CAS_Client(CAS_VERSION_2_0, true, Config::get('cas.hostname'), Config::get('cas.port'), Config::get('cas.context'));
$casClient->setNoCasServerValidation();
if (true === Config::get('pgtservice.enabled', false)) {
$casClient->setCallbackURL(Config::get('pgtservice.callback'));
$casClient->setPGTStorage(new ProxyTicketServiceStorage($casClient));
} else {
if (false !== Config::get('redis.hostname', false)) {
$casClient->setCallbackURL($this->url->getURL() . '/callback.php');
$redis = new \Redis();
$redis->connect(Config::get('redis.hostname'), Config::get('redis.port', 6379), 2, null, 100);
$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
$redis->setOption(\Redis::OPT_PREFIX, Config::get('application.project_name') . ':PHPCAS_TICKET_STORAGE:');
$redis->select((int) Config::get('redis.hostname', 2));
$casClient->setPGTStorage(new RedisTicketStorage($casClient, $redis));
} else {
$casClient->setCallbackURL($this->url->getURL() . '/callback.php');
$casClient->setPGTStorageFile(session_save_path());
// Handle logout requests but do not validate the server
$casClient->handleLogoutRequests(false);
}
}
// Accept all proxy chains
$casClient->getAllowedProxyChains()->allowProxyChain(new \CAS_ProxyChain_Any());
return $casClient;
}
示例13: auth
/**
* Check if user is authorized
*
* @return boolean true if access granted, false if no access
*/
function auth()
{
$cwd = getcwd();
chdir(dirname(dirname(dirname(dirname(dirname(__DIR__))))));
if (!defined('EP3_BS_DEV')) {
define('EP3_BS_DEV', false);
}
$config = (require 'config/autoload/global.php');
$sessionName = $config['session_config']['name'];
$sessionPath = $config['session_config']['save_path'];
if (isset($_COOKIE[$sessionName])) {
require 'vendor/zendframework/zendframework/library/Zend/Stdlib/Exception/ExceptionInterface.php';
require 'vendor/zendframework/zendframework/library/Zend/Stdlib/Exception/InvalidArgumentException.php';
require 'vendor/zendframework/zendframework/library/Zend/Stdlib/ArrayObject.php';
session_name($sessionName);
session_save_path($sessionPath);
session_start();
chdir($cwd);
if (isset($_SESSION['UserSession'])) {
$userSession = $_SESSION['UserSession'];
if ($userSession && $userSession instanceof Zend\Stdlib\ArrayObject) {
if ($userSession->uid && is_numeric($userSession->uid) && $userSession->uid > 0) {
if ($userSession->status && ($userSession->status == 'assist' || $userSession->status == 'admin')) {
return true;
}
}
}
}
}
return false;
}
示例14: __construct
public function __construct($Ethna_Backend)
{
$appid = $Ethna_Backend->getAppId();
session_save_path($Ethna_Backend->getTmpdir());
session_name($appid . 'SESSID');
return parent::__construct(array('session_name' => $appid . 'SESSID'));
}
示例15: __construct
function __construct($config)
{
if (!$config || !is_array($config)) {
$config["id"] = "PHPSESSID";
$config["path"] = "./data/session/";
$config["timeout"] = 3600;
}
$this->config($config);
$sid = $config["id"] ? $config["id"] : "PHPSESSION";
session_name($sid);
$this->sid = $sid;
$session_id = isset($_POST[$sid]) ? $_POST[$sid] : (isset($_GET[$sid]) ? $_GET[$sid] : "");
if ($session_id && preg_match("/^[a-z0-9A-Z\\_\\-]+\$/u", $session_id)) {
session_id($session_id);
$this->sessid = $session_id;
} else {
$this->sessid = session_id();
}
session_save_path($config["path"]);
$this->config = $config;
$this->timeout = $config["timeout"] ? $config["timeout"] : 600;
session_cache_expire(intval($this->timeout) / 60);
session_cache_limiter('public');
session_start();
}