本文整理汇总了PHP中Sessions类的典型用法代码示例。如果您正苦于以下问题:PHP Sessions类的具体用法?PHP Sessions怎么用?PHP Sessions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sessions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExitApplication
function ExitApplication($token)
{
if (!empty($token)) {
$session = new Sessions();
$session->ClearSession($token);
}
return;
}
示例2: isAdminSess
function isAdminSess()
{
$sessId = session_id();
$session = new Sessions();
$dbSessId = $session->sessionValid($sessId);
$myUser = null;
if (($dbData = $session->dataField($sessId)) != null) {
$myUser = $session->isAdmin($dbData);
}
if (!isset($dbSessId) || !isset($sessId) || !isset($myUser) || $sessId != $dbSessId) {
print "forwarded to the logout.php <br>";
header("Location: logout.php");
}
}
示例3: checkCRF
/**
* Check token submitted
* @param $token
* @return bool
*/
public static function checkCRF($token)
{
if (!$token) {
return false;
}
return Sessions::get('current_token') != trim($token) ? false : true;
}
示例4: getHandler
public static function getHandler()
{
if (self::$handler === false) {
self::$handler = new Sessions();
}
return self::$handler;
}
示例5: authenticate
public function authenticate()
{
$nick = strtolower($this->username);
$user = Users::model()->find('LOWER(email)=?', array($nick));
if ($user === null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} elseif (!$user->validatePassword($this->password, $user->salt)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} elseif ($user->status == 0) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
return 2;
} elseif ($user->status == 4) {
// user is banned
$this->errorCode = self::ERROR_PASSWORD_INVALID;
return 3;
} else {
$this->_id = $user->id;
$this->username = $user->email;
$this->setState('isAdmin', $user->status == 3);
$this->setState('permissions', $user->status);
$this->setState('nick', $user->nick);
$this->setState('session_key', md5($user->email . time() . uniqid() . $user->salt));
$this->setState('user_ip', Yii::app()->request->userHostAddress);
Sessions::model()->deleteAllByAttributes(array('user_id' => $user->id));
$this->errorCode = self::ERROR_NONE;
}
return $this->errorCode == self::ERROR_NONE;
}
示例6: Session
public function Session($Name, $Value = null)
{
$SESSIONS = new Sessions();
if ($Value) {
$SESSIONS->{$Name} = $Value;
$SESSIONS->Update();
} else {
$Value = $SESSIONS->Get($Name);
if ($Value) {
$SESSIONS->{$Name} = $Value;
$SESSIONS->Update();
}
}
unset($SESSIONS);
return $Value;
}
示例7: checkLoginState
/**
* 检查用户是否已经登录
* @param unknown_type $username
*/
public function checkLoginState($username)
{
$string = 's:' . strlen($username) . ':"' . $username . '"';
$criteria = new CDbCriteria();
$criteria->addSearchCondition('data', $string);
$model = Sessions::model()->find($criteria);
return $model;
}
示例8: logout
public function logout()
{
/*
* compares session token against get method to see if it's the actual user
*/
if (Sessions::get('token') == Requests::get('token')) {
Sessions::destroy();
}
}
示例9: getOnlineUsers
public static function getOnlineUsers()
{
$sessions = Sessions::model()->findAll();
$temp = array();
foreach ($sessions as $session) {
$temp[] = $session->user;
}
return $temp;
}
示例10: adminLoginNow
function adminLoginNow()
{
$username = $_REQUEST['login_user'];
$password = $_REQUEST['login_password'];
$admin = new administrator();
$admin->setUsername($username);
$data = $admin->getAdminFromUsername();
if (count($data) > 0) {
$admin->extractor($data);
if ($admin->password() == md5($password)) {
$session = new Sessions();
$session->setAdminLoginSessions($admin->id(), $admin->name(), $admin->email());
Common::jsonSuccess("Success");
} else {
Common::jsonError("Login Error");
}
} else {
Common::jsonError("Login Error");
}
}
示例11: updateMainCityImages
function updateMainCityImages()
{
$maincity = new MainCity();
$session = new Sessions();
$maincity->setMainCityId($session->getLastMainCityId());
$data = $maincity->getMainCityFromId();
$maincity->extractor($data);
$imgs = $maincity->mainCityImage();
if ($imgs != "") {
$imgs = $imgs . ',' . $_REQUEST['images'];
} else {
$imgs = $_REQUEST['images'];
}
$maincity->setMainCityImage($imgs);
if ($maincity->updateMainCityImages()) {
Common::jsonSuccess("Main City Update Successfully!");
} else {
Common::jsonError("Error");
}
}
示例12: __isAuthenticated
function __isAuthenticated()
{
return true;
if (array_key_exists('HTTP_AUTH_KEY', $_SERVER)) {
$authKey = $_SERVER['HTTP_AUTH_KEY'];
} elseif (array_key_exists('auth_key', $_GET)) {
$authKey = $_GET['auth_key'];
} else {
throw new RestException(401, 'Authentication Required');
}
$sessions = new Sessions();
$session = $sessions->verifySession($authKey);
if (is_array($session)) {
$sesInfo = $sessions->getSessionUser($authKey);
self::$userId = $sesInfo['USR_UID'];
self::$authKey = $authKey;
return true;
}
throw new RestException(401, 'Wrong Credentials!');
}
示例13: afterDelete
public function afterDelete()
{
parent::afterDelete();
$shared = Shared::model()->findAllByAttributes(array('cam_id' => $this->id));
foreach ($shared as $s) {
Notifications::model()->deleteAllByAttributes(array('shared_id' => $s->id, 'status' => 1));
$s->delete();
}
Sessions::model()->deleteAllByAttributes(array('real_id' => $this->id));
Sessions::model()->deleteAllByAttributes(array('real_id' => $this->id . '_low'));
return true;
}
示例14: add
public function add()
{
$name = $_POST["name"];
$lastname = $_POST["lastname"];
$email = $_POST["email"];
$pass = $_POST["pass"];
$conf = $_POST["conf"];
if ($name == null or $lastname == null or $email == null or $pass == null or $conf == null) {
header("location: Unirse.php?error=1");
} else {
if ($pass != $conf) {
header("location: Unirse.php?error=2");
} else {
$sql = "select * from usuario where Email='" . $email . "'";
$result = $this->cone->procedure($sql);
if ($result) {
if (!$result->fetch_assoc()) {
$sql = "select (count(idUsuario)+1) as 'newId' from usuario";
$result = $this->cone->procedure($sql);
if ($result) {
if ($row = $result->fetch_assoc()) {
$sql = "insert into Usuario values (" . $row['newId'] . ",'" . $name . "','" . $lastname . "','" . $email . "','" . $pass . "',null)";
$rs = $this->cone->procedure($sql);
if ($rs) {
$ses = new Sessions();
$ses->init();
$ses->set("user", $email);
header("location: ../User/index.php");
} else {
header("location: Unirse.php?error=3");
}
}
}
} else {
header("location: Unirse.php?error=4");
}
}
}
}
}
示例15: loginCheck
public static function loginCheck()
{
global $db;
if (Sessions::get("login")) {
$username = Session::get("login")['username'];
if ($username) {
$kontrol = $db->query("SELECT username FROM username = '{$username}'")->rowCount();
return $kontrol ? true : false;
}
} else {
return false;
}
}