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


PHP UserSession::save方法代码示例

本文整理汇总了PHP中UserSession::save方法的典型用法代码示例。如果您正苦于以下问题:PHP UserSession::save方法的具体用法?PHP UserSession::save怎么用?PHP UserSession::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserSession的用法示例。


在下文中一共展示了UserSession::save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testIndexNoAdmin

	public function testIndexNoAdmin()
	{
		$s = new UserSession('azerty', 'azerty');
		$s->save();
		
		$this->request('admin');
		
		$this->assertRedirected('');
		$this->assertFlashError('You don\'t have the rights to view this page');
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:10,代码来源:admin.controller.Test.php

示例2: createForUser

 /**
  * @param $user User
  * @param $sessionOnly boolean
  * @param null $expireDate int
  * @return UserSession
  */
 public static function createForUser($user, $expireDate)
 {
     $session = new UserSession();
     $session->user = $user->id;
     $session->token = Auth::generateSessionToken($user->salt);
     $session->createDate = Database::now();
     $session->expireDate = CommonUtil::sqlTimeStamp($expireDate);
     $session->expired = 0;
     $session->save();
     return $session;
 }
开发者ID:pvpalvk,项目名称:kyberkoulutus2,代码行数:17,代码来源:UserSession.php

示例3: executeLogin

	/**
	 * @post
	*/
	public function executeLogin($username, $password, $redirect = '/')
	{
		$session = new UserSession($username, $password);
		
		try
		{
			$session->save();
			$this->notice(t('You are now logged in'));
			$this->redirect($redirect);
		}
		catch (ValidationException $e)
		{
			$this->error(t('You are not logged in'));
			$this->redirect = $redirect;
			$this->session = $session;
			$this->render('login');
		}
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:21,代码来源:user.controller.php

示例4: checkAuthentication

 public function checkAuthentication()
 {
     $this->user = null;
     if (isset($_COOKIE[$this->cookie_name])) {
         $arr = explode('-', $_COOKIE[$this->cookie_name]);
         $session_id = intval($arr[0]);
         $session_token = $arr[1];
     }
     if (isset($session_id)) {
         $this->session = new UserSession($this->db, $session_id);
         if (isset($this->session) && $this->session->is_loaded && Authentication::verifyPassword($session_token, $this->session->val('user_session_token_hash'))) {
             $expires = time() + Authentication::$session_expire;
             $session = new UserSession($this->db);
             $session->data['user_session_id'] = $session_id;
             $session->data['user_session_expires'] = SqlQuery::mysqlTimestamp($expires);
             $session->save();
             setcookie($this->cookie_name, $this->session->val('user_session_id') . '-' . $session_token, $expires, '/', false, false);
             $this->user = new User($this->db, $this->session->val('user_session_user_id'));
             $this->updateLastAccess();
         }
     }
 }
开发者ID:lotcz,项目名称:zshop,代码行数:22,代码来源:authentication.php

示例5: doLogin

 /**
  * @remotable
  * @formHandler
  */
 public function doLogin($params)
 {
     $userName = $params['login'];
     $isDesktop = false;
     if (isset($params['isdesktop'])) {
         $isDesktop = true;
     }
     $this->setSessionValue('isDesktop', $isDesktop);
     $q = Doctrine_Query::create()->select("u.*")->from("User u")->where('u.login = ?', $userName)->andWhere('u.isActive = ?', 1);
     $user = $q->fetchOne();
     if (isset($params['password'])) {
         $success = $user != null && $user->password == $this->generateHash($params['password']);
     } else {
         $success = $user != null && $user->devicePin == $params['devicePin'];
     }
     if ($success) {
         //detect environments and set debug: 0:false/debug off 1:true/debug on
         $fullPath = $_SERVER["REQUEST_URI"];
         if (stristr($fullPath, "uat")) {
             $userSession->debug = 1;
         } elseif (stristr($fullPath, "moqoldWeb")) {
             $userSession->debug = 1;
         } else {
             $userSession->debug = 0;
         }
         $this->setSessionValue('user', $user->ID);
         $this->setSessionValue('userRole', $user->userRoleID);
         $this->setSessionValue('contactID', $user->contactID);
         $userSession = new UserSession();
         $userSession->userID = $user->ID;
         $userSession->hostIP = $this->getRealIpAddr();
         $userSession->userAgent = $_SERVER['HTTP_USER_AGENT'];
         //$userSession->refererName = -- useless in AJAX apps
         $userSession->startTime = $this->getDateFormat();
         $userSession->endTime = $userSession->startTime;
         $userSession->save();
         $this->setSessionValue('sessionId', $userSession->ID);
     }
     return $this->isLoggedIn($isDesktop);
 }
开发者ID:unixmiah,项目名称:codeigniter-doctrine-extjs,代码行数:44,代码来源:LoginAPI.php

示例6: login

	private function login($u)
	{
		$s = new UserSession($u, $u);
		$s->save();
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:5,代码来源:admin.user.controller.Test.php

示例7: login

	private function login($name)
	{
		$s = new UserSession($name, $name);
		$s->save();
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:5,代码来源:admin.layout.controller.Test.php

示例8: login

	private function login($user = 'dvorak')
	{
		$s = new UserSession($user, $user);
		$s->save();
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:5,代码来源:acl.before.Test.php

示例9: login

	private function login($u = 'nathan')
	{
		$session = new UserSession($u, $u);
		$session->save();
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:5,代码来源:blog.controller.Test.php

示例10: testModelsNoAdmin

	public function testModelsNoAdmin()
	{
		$s = new UserSession('azerty', 'azerty');
		$s->save();
		$modules = Admin::modules();
		
		$this->assertNull($modules);
		
		$s->delete();
		$modules = Admin::modules();
		$this->assertNull($modules);
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:12,代码来源:admin.model.Test.php

示例11: testUserLocked

	public function testUserLocked()
	{
		$user = new User;
		$user->username = 'someuser';
		$user->email = 'someuser@somemail.com';
		$user->password = 'thepass';
		$user->passwordConfirmation = 'thepass';
		$key = $user->save();
		
		$session = new UserSession('someuser', 'thepass');
		try
		{
			$session->save();
			$this->fail('Expected exception');
		}
		catch (ValidationException $e)
		{
			$this->assertEquals('User is not activated', 
			                    $session->username_error);
		}
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:21,代码来源:usersession.model.Test.php


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