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


PHP Session::has方法代碼示例

本文整理匯總了PHP中yii\web\Session::has方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::has方法的具體用法?PHP Session::has怎麽用?PHP Session::has使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\web\Session的用法示例。


在下文中一共展示了Session::has方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getEncodingLevel

 public function getEncodingLevel()
 {
     $session = new Session();
     $session->open();
     if (!$session->has('eyes_admin')) {
         $session['eyes_admin'] = false;
     }
     if (!$session->has('eyes_encrypted')) {
         $session['eyes_encrypted'] = true;
     }
     //Check if we are unencrypted and a guest. If so, return "UNENCRYPTED".
     if (($this->key == "" || $this->key == null) && Yii::$app->user->isGuest) {
         return 0;
     }
     //Check if the current user is a guest. If so, return "ENCRYPTED".
     if (Yii::$app->user->isGuest) {
         return 2;
     }
     //Get our current user.
     $user = User::find()->where(['id' => Yii::$app->user->identity->id])->one();
     //Check if we are the owner of the message. If so, return "OWNER".
     if ($this->owner == $user->username) {
         return 3;
     }
     //Check if we are unencrypted. If so, return "UNENCRYPTED".
     if ($this->key == "" || $this->key == null) {
         return 0;
     }
     //Check if we have the key needed. If so, return "DECRYPTED".
     if ($user->hasKey($this->key)) {
         return 1;
     }
     //The message is encrypted. Check if have admin eyes. If so, return "ADMIN_EYES".
     //TODO admin eyes is currently unimplemented.
     $adminEyes = $session['eyes_admin'];
     if ($adminEyes) {
         return 4;
     } else {
         return 2;
     }
 }
開發者ID:bryantmakesprog,項目名稱:TwitterClone,代碼行數:41,代碼來源:Tweet.php

示例2: Session

<?php

/*
 * Pass an array of Tweet models to $tweets.
 */
use app\models\Tweet;
use yii\widgets\LinkPager;
use yii\web\Session;
//Check for view variables.
$session = new Session();
$session->open();
if (!$session->has('eyes_admin')) {
    $session['eyes_admin'] = false;
}
if (!$session->has('eyes_encrypted')) {
    $session['eyes_encrypted'] = true;
}
?>
        
<div class="body-content">
    
<?php 
echo $this->render('_toolbar');
$i = 0;
$renderedForm = false;
foreach ($tweets as $message) {
    //Open a new row.
    if ($i == 0) {
        echo "<div class='row'>";
    }
    if (!$renderedForm && !Yii::$app->user->isGuest) {
開發者ID:bryantmakesprog,項目名稱:TwitterClone,代碼行數:31,代碼來源:gridview.php


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