當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Sessions類代碼示例

本文整理匯總了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;
 }
開發者ID:brahimmachkouri,項目名稱:phpDHCPAdmin,代碼行數:8,代碼來源:class.cleanup.php

示例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");
     }
 }
開發者ID:nateirwin,項目名稱:custom-historic,代碼行數:14,代碼來源:StoreSession.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;
 }
開發者ID:rivomanana,項目名稱:rv-slim-base,代碼行數:12,代碼來源:Token.php

示例4: getHandler

 public static function getHandler()
 {
     if (self::$handler === false) {
         self::$handler = new Sessions();
     }
     return self::$handler;
 }
開發者ID:ekowabaka,項目名稱:wyf,代碼行數:7,代碼來源:Sessions.php

示例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;
 }
開發者ID:mrtos,項目名稱:OpenNVR,代碼行數:28,代碼來源:UserIdentity.php

示例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;
 }
開發者ID:baiduXM,項目名稱:agent,代碼行數:16,代碼來源:class.UsersModule.php

示例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;
 }
開發者ID:yunsite,項目名稱:my-advertise,代碼行數:12,代碼來源:LoginForm.php

示例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();
     }
 }
開發者ID:nc1991,項目名稱:Basic-MVC,代碼行數:9,代碼來源:UserController.php

示例9: getOnlineUsers

 public static function getOnlineUsers()
 {
     $sessions = Sessions::model()->findAll();
     $temp = array();
     foreach ($sessions as $session) {
         $temp[] = $session->user;
     }
     return $temp;
 }
開發者ID:netconstructor,項目名稱:X2Engine,代碼行數:9,代碼來源:SessionChild.php

示例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");
    }
}
開發者ID:jcodesdotme,項目名稱:pp,代碼行數:20,代碼來源:login-controller.php

示例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");
    }
}
開發者ID:jcodesdotme,項目名稱:pp,代碼行數:20,代碼來源:maincity-controller.php

示例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!');
 }
開發者ID:emildev35,項目名稱:processmaker,代碼行數:20,代碼來源:Auth.php

示例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;
 }
開發者ID:mrtos,項目名稱:OpenNVR,代碼行數:12,代碼來源:Cams.php

示例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");
                 }
             }
         }
     }
 }
開發者ID:BryanPalacios,項目名稱:AppMul_ProyectoF,代碼行數:40,代碼來源:AddUser.php

示例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;
     }
 }
開發者ID:vahitserifsaglam1,項目名稱:ozsa-src,代碼行數:13,代碼來源:Security.php


注:本文中的Sessions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。