本文整理汇总了PHP中yii\web\Session::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::close方法的具体用法?PHP Session::close怎么用?PHP Session::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\Session
的用法示例。
在下文中一共展示了Session::close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterAction
/**
* @param \yii\base\Action $action
* @param mixed $result
* @return mixed
*/
public function afterAction($action, $result)
{
if ($this->session->isActive) {
$this->session->close();
}
return parent::afterAction($action, $result);
}
示例2: actionLogin
public function actionLogin()
{
$modelLoginFrom = new LoginForm();
if ($modelLoginFrom->load(\Yii::$app->getRequest()->getBodyParams(), '') && $modelLoginFrom->login()) {
$post = \Yii::$app->getRequest()->getBodyParams();
$modelUser = new User();
$modelRole = new Role();
$result = $modelRole->find()->where(['=', 'role_id', \Yii::$app->user->identity->getRole()])->all();
$resultuserdata = $modelUser->find()->where(['=', 'username', $post['username']])->one();
$session = new Session();
$session->open();
$session->set('role', $result[0]->name);
$session->close();
return ['username' => $post['username'], 'role' => $result[0]->name, 'isLogined' => true, 'userDataID' => $resultuserdata->user_data_id];
} else {
return $modelLoginFrom;
}
}
示例3: actionToggleAdminEyes
public function actionToggleAdminEyes()
{
$session = new Session();
$session->open();
$session['eyes_admin'] = !$session['eyes_admin'];
$session->close();
return $this->redirect(Yii::$app->request->referrer);
}
示例4: actionSetwindowguid
public function actionSetwindowguid()
{
$guid = (string) filter_input(INPUT_POST, 'guid');
$pathname = (string) filter_input(INPUT_POST, 'path');
$search = (string) filter_input(INPUT_POST, 'search');
$session = new Session();
$session->open();
$res = isset($session['WindowsGUIDs']) ? $session['WindowsGUIDs'] : [];
$currentguid = $session['WindowsGUIDCurrent'];
$gohome = false;
$homeurls = ["", "?r=site%2Findex", "?r=site%2Flogin", "?r=site%2Flogout", "?r=site%2Ferror"];
$ishome = in_array($search, $homeurls);
if (empty($guid)) {
// Если новая вкладка
for ($i = 0; $i < 6; $i++) {
$guid .= dechex(rand(0, 15));
}
$res[$guid] = 1;
$session['WindowsGUIDs'] = $res;
$session['WindowsGUIDCurrent'] = $guid;
$gohome = !$ishome;
} else {
// Если существующая вкладка
if ($session['WindowsGUIDCurrent'] === $guid) {
// Если текущая вкладка
} else {
// Если другая существующая вкладка
$session['WindowsGUIDCurrent'] = $guid;
$gohome = !$ishome;
}
$session['WindowsGUIDs'] = $res;
}
$session->close();
echo json_encode((object) ['guid' => $guid, 'gohome' => $gohome]);
}
示例5: isset
),
]);
NavBar::end();
} */
?>
<?php
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 'homeLink' => ['url' => Yii::$app->homeUrl, 'label' => '<span class="bc_lighter"></span><i class="glyphicon glyphicon-home"></i>', 'encode' => false]]);
?>
<?php
if (!isset($this->params['breadcrumbs'])) {
$session = new Session();
$session->open();
$session->remove('breadcrumbs');
$session->close();
}
?>
<?php
echo $content;
?>
</div>
<div class="buttonside" id="scrollupbutton" style="display: none;">
<span>ВВЕРХ</span>
</div>
<a class="buttonside" id="backbutton" href="<?php
echo Proc::GetPreviousURLBreadcrumbsFromSession() === Yii::$app->homeUrl ? '#' : Proc::GetPreviousURLBreadcrumbsFromSession();
?>
" style="display: none;">
<span>НАЗАД</span>
示例6: AssignToModelFromGrid
/**
* Присваивает выбранное значение из справочника модели, в сессии.
* При выборе значения из справочника, значение присваивается в сессию предыдущей хлебной крошки, для формы, с которой был открыт справочник.
* @param bool $RedirectPreviousUrl
* @param ActiveRecord $ActiveRecord Модель к которой присваивается знаечния из справочника.
* @param string $AttributeForeignID Имя атрибута
* @return string
*/
public static function AssignToModelFromGrid($RedirectPreviousUrl = True, $ActiveRecord = NULL, $AttributeForeignID = NULL)
{
if (Yii::$app->request->isAjax) {
$LastBC = Proc::GetLastBreadcrumbsFromSession();
$assigndata = filter_input(INPUT_POST, 'assigndata');
$foreign = isset($LastBC['dopparams']['foreign']) ? $LastBC['dopparams']['foreign'] : '';
if (!empty($foreign) && !empty($assigndata)) {
$BC = Proc::GetBreadcrumbsFromSession();
end($BC);
prev($BC);
$BC[key($BC)]['dopparams'][$foreign['model']][$foreign['field']] = $assigndata;
$session = new Session();
$session->open();
$session['breadcrumbs'] = $BC;
$session->close();
if ($ActiveRecord instanceof ActiveRecord && is_string($AttributeForeignID)) {
$field = $LastBC['dopparams']['foreign']['field'];
if ($ActiveRecord->formName() === $LastBC['dopparams']['foreign']['model']) {
$ActiveRecord->{$field} = $assigndata;
$ActiveRecord->{$AttributeForeignID} = $foreign['id'];
if ($ActiveRecord->validate()) {
$ActiveRecord->save(false);
}
}
}
if ($RedirectPreviousUrl) {
Yii::$app->response->redirect(Proc::GetPreviousURLBreadcrumbsFromSession());
}
} else {
return 'error foreign or assigndata empty AssignToModelFromGrid()';
}
}
}