本文整理汇总了PHP中Session::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::create方法的具体用法?PHP Session::create怎么用?PHP Session::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
function show()
{
$method = HTTP::_GP('method', '');
$method = strtolower(str_replace(array('_', '\\', '/', '.', ""), '', $method));
$path = 'includes/classes/extauth/' . $method . '.class.php';
if (!file_exists($path)) {
HTTP::redirectTo('index.php');
}
$session = Session::create();
require 'includes/classes/extauth/externalAuth.interface.php';
require $path;
$methodClass = ucwords($method) . 'Auth';
/** @var $authObj externalAuth */
$authObj = new $methodClass();
if (!$authObj->isActiveMode()) {
$session->delete();
$this->redirectTo('index.php?code=5');
}
if (!$authObj->isValid()) {
$session->delete();
$this->redirectTo('index.php?code=4');
}
$loginData = $authObj->getLoginData();
if (empty($loginData)) {
$session->delete();
$this->redirectTo('index.php?page=register&externalAuth[account]=' . $authObj->getAccount() . '&externalAuth[method]=facebook');
}
$session->userId = (int) $loginData['id'];
$session->adminAccess = 0;
$session->save();
$this->redirectTo("game.php");
}
示例2: Create
public static function Create($p_sessionId, &$p_objectId, $p_objectTypeId = null, $p_userId = null, $p_updateStats = false)
{
if (empty($p_sessionId)) {
throw new SessionIdNotSet();
}
$session = new Session($p_sessionId);
if (!$session->exists()) {
$sessionParams = array('start_time' => strftime("%Y-%m-%d %T"));
if (!empty($p_userId)) {
$sessionParams['user_id'] = $p_userId;
}
$session->create($sessionParams);
}
$sessionUserId = $session->getUserId();
if (!empty($p_userId) && !empty($sessionUserId) && $sessionUserId != $p_userId) {
throw new InvalidUserId();
}
$requestObject = new RequestObject($p_objectId);
if (!$requestObject->exists()) {
if (empty($p_objectTypeId)) {
throw new ObjectTypeIdNotSet();
}
$requestObject->create(array('object_type_id' => $p_objectTypeId));
$p_objectId = $requestObject->getObjectId();
} elseif (empty($p_objectId)) {
throw new ObjectIdNotSet();
}
if ($p_updateStats) {
self::UpdateStats($p_sessionId, $p_objectId);
}
}
示例3: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Session::create([]);
}
}
示例4: show
function show()
{
if (empty($_POST)) {
HTTP::redirectTo('index.php');
}
$db = Database::get();
$username = HTTP::_GP('username', '', UTF8_SUPPORT);
$password = HTTP::_GP('password', '', true);
$sql = "SELECT id, password FROM %%USERS%% WHERE universe = :universe AND username = :username;";
$loginData = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $username));
if (isset($loginData)) {
$hashedPassword = PlayerUtil::cryptPassword($password);
if ($loginData['password'] != $hashedPassword) {
// Fallback pre 1.7
if ($loginData['password'] == md5($password)) {
$sql = "UPDATE %%USERS%% SET password = :hashedPassword WHERE id = :loginID;";
$db->update($sql, array(':hashedPassword' => $hashedPassword, ':loginID' => $loginData['id']));
} else {
HTTP::redirectTo('index.php?code=1');
}
}
$session = Session::create();
$session->userId = (int) $loginData['id'];
$session->adminAccess = 0;
$session->save();
HTTP::redirectTo('game.php');
} else {
HTTP::redirectTo('index.php?code=1');
}
}
示例5: createForLogin
public static function createForLogin($app, $steamID, $user)
{
$steamProfile = $app->steam->getUser($steamID);
$steamInventory = $app->steam->getInventory($steamID);
$steamBans = $app->steam->getBans($steamID);
if ($app->config->get('mode') == 'production') {
if (!empty($steamProfile->timecreated) && time() - $steamProfile->timecreated < Steam::STEAM_AGE_THRESHOLD) {
throw new User_TooNew();
}
}
if (!empty($steamBans->VACBanned)) {
throw new User_SteamBanned('VAC Banned');
}
if (!empty($steamBans->CommunityBanned)) {
throw new User_SteamBanned('Steam Community Banned');
}
if (!empty($steamBans->EconomyBan) && strcmp($steamBans->EconomyBan, 'none') != 0) {
throw new User_SteamBanned('Steam Economy Banned');
}
$hash = Session::createHash($steamID);
$session = Session::create(['hash' => $hash, 'user_id' => $steamID, 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'ip' => $_SERVER['REMOTE_ADDR']]);
$user->name = $steamProfile->personaname;
$user->profile_private = $steamProfile->communityvisibilitystate == 3 ? 0 : 1;
$user->inventory_private = $steamInventory ? 0 : 1;
$user->ip_last = $_SERVER['REMOTE_ADDR'];
if (empty($user->ip_register)) {
$user->ip_register = $_SERVER['REMOTE_ADDR'];
$user->name_register = $steamProfile->personaname;
}
$user->save();
setcookie('csgoshop_session', $hash, time() + 60 * 60 * 24 * 30, '/');
setcookie('csrf', $session->csrf_token, time() + 60 * 60 * 24 * 30, '/');
}
示例6: get_session
public static function get_session()
{
if (!self::$session) {
// Generate the session ID. This is slightly wasteful.
$data = array();
$data['type'] = 'stream';
// This shouldn't be done here but at backend endpoint side
if (isset($_REQUEST['client'])) {
$data['agent'] = $_REQUEST['client'];
}
// Copy session geolocation
// Same thing, should be done elsewhere
$sid = session_id();
if ($sid) {
$location = Session::get_geolocation($sid);
if (isset($location['latitude'])) {
$data['geo_latitude'] = $location['latitude'];
}
if (isset($location['longitude'])) {
$data['geo_longitude'] = $location['longitude'];
}
if (isset($location['name'])) {
$data['geo_name'] = $location['name'];
}
}
self::$session = Session::create($data);
}
return self::$session;
}
示例7: login
public static function login($model){
$model = self::authenticate($model);
if(!$model['valid']){
return $model;
}
return Session::create($model);
}
示例8: show
function show()
{
$userData = $this->_activeUser();
$session = Session::create();
$session->userId = (int) $userData['userID'];
$session->adminAccess = 0;
$session->save();
HTTP::redirectTo('game.php');
}
示例9: change_password
private function change_password($user_id, $change_password_pass, $password)
{
PHPBoostAuthenticationMethod::update_auth_infos($user_id, null, null, KeyGenerator::string_hash($password), null, '');
$session = AppContext::get_session();
if ($session != null) {
Session::delete($session);
}
AppContext::set_session(Session::create($user_id, true));
AppContext::get_response()->redirect(Environment::get_home_page());
}
示例10: needSession
/**
* Method to load and check if a session is available.
* @param string $redirectURL The url which will be used for redirect.
* @since 0.0.1-dev
*/
protected function needSession($redirectURL = URL)
{
//create the session.
$session = new Session();
$session->create(Database::getInstance()->getConnection());
//check if the session is available.
if (isset($_SESSION['user_username']) === false) {
$this->redirect($redirectURL);
}
}
示例11: login
public function login($login, $password)
{
$results = $this->db_handler->query('SELECT id FROM users WHERE login = "' . $login . '" AND password = "' . hash('sha256', $_POST['password']) . '"');
$user = $results->fetch_assoc();
if ($results->num_rows) {
Session::create($user['id']);
return true;
} else {
return false;
}
}
示例12: testCreateAndDestroy
public function testCreateAndDestroy()
{
Session::create(__FILE__);
$instance1 = Session::getCurrent();
Session::create(__FILE__);
$instance2 = Session::getCurrent();
$instance3 = Session::getCurrent();
Session::destroy();
$instance4 = Session::getCurrent();
$this->assertSame($instance1, $instance4);
$this->assertSame($instance2, $instance3);
$this->assertTrue($instance1 !== $instance2);
}
示例13: authenticate
/**
* @desc Tries to authenticate the user using the given authentication method.
* @param AuthenticationMethod $authentication the authentication method to use
* @param bool $autoconnect If true, an autoconnect cookie will be created
* @return int $user_id, if authentication has been performed successfully
*/
public static function authenticate(AuthenticationMethod $authentication, $autoconnect = false)
{
$user_id = $authentication->authenticate();
if ($user_id) {
$session = AppContext::get_session();
if ($session != null) {
Session::delete($session);
}
$session_data = Session::create($user_id, $autoconnect);
AppContext::set_session($session_data);
}
return $user_id;
}
示例14: check_activation
private function check_activation($registration_pass)
{
$user_id = PHPBoostAuthenticationMethod::registration_pass_exists($registration_pass);
if ($user_id) {
PHPBoostAuthenticationMethod::update_auth_infos($user_id, null, true, null, '');
$session = AppContext::get_session();
if ($session != null) {
Session::delete($session);
}
AppContext::set_session(Session::create($user_id, true));
AppContext::get_response()->redirect(Environment::get_home_page());
} else {
$controller = new UserErrorController($this->lang['profile'], LangLoader::get_message('process.error', 'status-messages-common'), UserErrorController::WARNING);
DispatchManager::redirect($controller);
}
}
示例15: login
public static function login($email, $password, $remember)
{
$row = self::find_one_by(array('user_email' => $email, 'user_status' => St::VALID));
if (empty($row)) {
return false;
}
if ($row->user_password != Auth::hash_password($password)) {
return false;
}
$row->user_last_login = System::now();
$row->save();
Session::create();
$close = !(bool) $remember;
Session::set('expire_on_close', $close);
Session::set(self::$_table_name, $row);
return true;
}