当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::create方法代码示例

本文整理汇总了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");
 }
开发者ID:tatarysh,项目名称:2Moons,代码行数:32,代码来源:ShowExternalAuthPage.class.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);
     }
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:31,代码来源:SessionRequest.php

示例3: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Session::create([]);
     }
 }
开发者ID:dynamicsystems,项目名称:TechTracker,代码行数:7,代码来源:SessionsTableSeeder.php

示例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');
     }
 }
开发者ID:tatarysh,项目名称:2Moons,代码行数:30,代码来源:ShowLoginPage.class.php

示例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, '/');
 }
开发者ID:puttyplayer,项目名称:CSGOShop,代码行数:33,代码来源:Session.php

示例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;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:29,代码来源:stream.class.php

示例7: login

		public static function login($model){
			$model = self::authenticate($model);
			
			if(!$model['valid']){
				return $model;
			}
			
			return Session::create($model);
		}
开发者ID:nimitz92,项目名称:snowblozm-lite,代码行数:9,代码来源:User.class.php

示例8: show

 function show()
 {
     $userData = $this->_activeUser();
     $session = Session::create();
     $session->userId = (int) $userData['userID'];
     $session->adminAccess = 0;
     $session->save();
     HTTP::redirectTo('game.php');
 }
开发者ID:tatarysh,项目名称:2Moons,代码行数:9,代码来源:ShowVertifyPage.class.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());
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:10,代码来源:UserChangeLostPasswordController.class.php

示例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);
     }
 }
开发者ID:Clanify,项目名称:Clanify,代码行数:15,代码来源:Controller.php

示例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;
     }
 }
开发者ID:b4naser,项目名称:social_website,代码行数:11,代码来源:auth.class.php

示例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);
 }
开发者ID:mlessnau,项目名称:pry,代码行数:13,代码来源:SessionTest.php

示例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;
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:19,代码来源:AuthenticationService.class.php

示例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);
     }
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:16,代码来源:UserConfirmRegistrationController.class.php

示例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;
 }
开发者ID:marietta-adachi,项目名称:website,代码行数:17,代码来源:user.php


注:本文中的Session::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。