static function begin() { if (!headers_sent()) { self::setupSessionCookie(); session_start(); } self::$id = session_id(); }
public static function start() { if (self::$started) { return; } self::read(); self::$started = true; $result = Db::row("SELECT u.id_personas\n , CONCAT(u.nombre, ' ', u.apellido) AS nombre\n FROM personas u\n WHERE u.usuario = '" . self::$usuario . "'\n AND u.contrasena = '" . self::$contrasena . "'\n LIMIT 1"); self::$id = $result['id_personas']; self::$nombre = $result['nombre']; }
function start() { if (!self::$started) { self::var_setup(); self::ini_setup(); self::$user_agent = $_SERVER['HTTP_USER_AGENT']; self::$ip = $_SERVER['REMOTE_ADDR']; if (!self::$session_use_only_cookies && array_key_exists('sess_id', $_REQUEST)) { session_id($_REQUEST['sess_id']); } session_start(); self::$id = session_id(); self::$started = true; self::validate(); } }
/** * Méthode d'initialisation de la session utilisateur. * Cette méthode vide le contenu de $_SESSION pour remplir les propriété statiques * de la classe Session. */ static function Init() { if (self::$state === false) { self::$session = $_SESSION; $_SESSION = []; if (isset(self::$session['id'], self::$session['first_name'], self::$session['last_name'], self::$session['accountant'])) { self::$id = self::$session['id']; self::$first_name = self::$session['first_name']; self::$last_name = self::$session['last_name']; self::$accountant = self::$session['accountant']; } else { self::$id = null; self::$first_name = null; self::$last_name = null; self::$accountant = null; } self::$state = true; } }
static function start() { if (!self::$id) { ini_set('session.name', self::$session_name); ini_set('session.cookie_lifetime', self::$session_lifetime); ini_set('session.gc_probability', 1); ini_set('session.gc_maxlifetime', self::$session_max_lifetime * 60); ini_set('session.use_trans_sid', self::$session_no_cookies); ini_set('arg_separator.output', "/"); header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); self::$ip = $_SERVER['REMOTE_ADDR']; self::$user_agent = $_SERVER['HTTP_USER_AGENT']; # Don't start a session if this is a search engine if (self::is_bot()) { return false; } if (self::is_valid_host() && $_REQUEST[self::$session_name]) { session_id($_REQUEST[self::$session_name]); } session_cache_limiter("must-revalidate"); session_start(); self::$id = session_id(); } }
/** +---------------------------------------------------------- * Session 初始化 +---------------------------------------------------------- * @static * @access private +---------------------------------------------------------- * @return boolean +---------------------------------------------------------- */ static function _init() { ini_set('session.auto_start', 0); if (is_null(Session::detectID())) { Session::id(uniqid(dechex(mt_rand()))); } // 设置Session有效域名 Session::setCookieDomain(C('COOKIE_DOMAIN')); //设置当前项目运行脚本作为Session本地名 Session::localName(APP_NAME); Session::name(C('SESSION_NAME')); Session::path(C('SESSION_PATH')); Session::setCallback(C('SESSION_CALLBACK')); }
// if an href is passed in $SESSION->set("href", $REQUEST->get("href")); } else { // otherwise, assume the base file $SESSION->set("href", "/"); } // get the provider_name and save it $SESSION->set("provider_name", $REQUEST->get("provider")); $Auth = $OAuth($REQUEST->get("provider"), $SESSION->id()); // call the redirect function to get the right URL echo $Auth->getURL($SESSION->id(), $REQUEST->get("scope")); // Runs if there is not an error, and the function can continue // to execute until the redirect } else { if ($REQUEST->avail("code") && $REQUEST->avail("state")) { // get back your session from state $SESSION = new Session($REQUEST->get("state")); $Auth = $OAuth($SESSION->get("provider")["provider_name"], $SESSION->id()); $access_token = $Auth->exchange($REQUEST->get("code"), $SESSION->id()); $Auth->save($access_token, $SESSION->id()); OAuth::redirect($SESSION->get("access_token"), $SESSION->id()); // runs if there is an error with the Redirect URL } else { if ($REQUEST->avail("error")) { echo $REQUEST->get("error"); // Runs on a weird unknown error } else { $OUTPUT->error(2, "OAuth Provider is not properly set-up"); } } }
<?php declare (strict_types=1); use Airship\Engine\{AutoPilot, State}; use ParagonIE\Cookie\{Cookie, Session}; /** * @global State $state */ // Start the session if (!Session::id()) { if (!isset($state)) { $state = State::instance(); } $session_config = ['use_strict_mode' => true, 'entropy_length' => 32, 'cookie_httponly' => true, 'cookie_secure' => AutoPilot::isHTTPSConnection()]; if (isset($state->universal['session_config'])) { $session_config = $state->universal['session_config'] + $session_config; if (isset($session_config['cookie_domain'])) { if ($session_config['cookie_domain'] === '*' || \trim($session_config['cookie_domain']) === '') { unset($session_config['cookie_domain']); } } } if (\PHP_VERSION_ID >= 70100) { // Forward compatibility. unset($session_config['entropy_length']); } Session::start(Cookie::SAME_SITE_RESTRICTION_STRICT, $session_config); } if (empty($_SESSION['created_canary'])) { // We haven't seen this session ID before $_SESSION = [];
function __construct() { session_start(); self::$id = session_id(); self::upDate(); }
} } // Security : The session is wiped if the user-agent change if (Session::exists('HTTP_USER_AGENT')) { if (Session::read('HTTP_USER_AGENT') != $_SERVER['HTTP_USER_AGENT']) { Session::regenerate_id(); Session::wipe(); Session::write('HTTP_USER_AGENT', $_SERVER['HTTP_USER_AGENT']); } } else { Session::write('HTTP_USER_AGENT', $_SERVER['HTTP_USER_AGENT']); } // Security : The page is reloaded without session id in the URL if the session id is present in the URL if (strpos($_SERVER['REQUEST_URI'], Session::name()) && count($_POST) == 0) { Session::close(); setcookie(Session::name(), Session::id(), null, '/', '.' . $domaine); $page_address = preg_replace('#(?<=&|\\?)' . Session::name() . '=[^&]+(?:&|$)#', '', $_SERVER['REQUEST_URI']); $page_address = rtrim($page_address, '?&'); header('Location: http://' . $_SERVER['HTTP_HOST'] . $page_address); exit; } // Security : The $_POST variables are wiped if the referer domain is different from the current domain if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '' && !preg_match('#^https?://' . preg_quote($_SERVER['SERVER_NAME']) . '#', $_SERVER['HTTP_REFERER'])) { // On vide $_POST $_POST = array(); } // Removing special characters from $_POST variables (they may be a problem with DB or AJAX) foreach ($_POST as $key => $value) { if (!is_array($value)) { $value = preg_replace('#[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F]#', '', $value); }
/** * Start or continue a session * * @uses ini_set() * @uses $ip * @uses is_valid_host() * @uses session_id() * @uses session_start() * @uses $user_agent */ function start_session() { if (!self::$started) { self::init(); header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"'); self::$ip = self::get_client_ip(); self::$user_agent = $_SERVER['HTTP_USER_AGENT']; if (self::is_valid_host() && array_key_exists('sess_id', $_REQUEST)) { session_id($_REQUEST['sess_id']); } session_cache_limiter("must-revalidate"); session_start(); self::$id = session_id(); self::$started = true; } $hash = self::get_hash(); if (!isset($_SESSION[$hash])) { $_SESSION[$hash] = array(); } }
body { font-family:Verdana, Geneva, sans-serif; font-size: 13px; color: #333; margin: 0; } .plupload_container {padding: 0;}; </style> </head> <body > <div id="uploader" style="width:100%;height:10%;">Your browser doesn't support upload.</div> <script type="text/javascript"> $(function () { // 配置参数 // app.debug = true; app.api = { key: 'KHSDLG80346JJSDG', url: './webftp.php?mod=nfs&act=upload', path: '/?/', cover: 0, webftp_sessid: '<?php echo Session::id(); ?> ', webftp_uname: '<?php echo Cookie::get('uname'); ?> ', webftp_tokey: '<?php echo Cookie::get('tokey'); ?> ' }; app.settings = { max_file_size: '<?php echo C('UPLOAD.MAX_FILE_SIZE');
public static function token() { return $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . Session::id(); }
static function setExpire($time) { setcookie(Session::name(), Session::id(), time() + $time, '/'); }