本文整理汇总了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;
}
}
示例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) {