博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cms 单点登录 php,Yii2 中实现单点登录的方法
阅读量:1531 次
发布时间:2019-04-21

本文共 752 字,大约阅读时间需要 2 分钟。

本文介绍了Yii2 中实现单点登录的方法,分享给大家,具体如下:

修改 /common/config/main.php

一、在 config 头部上加上以下代码

// Session 跨域

$host = explode('.', $_SERVER["HTTP_HOST"]);

if (count($host) > 2) {

define('DOMAIN', $host[1] . '.' . $host[2]);

} else {

define('DOMAIN', $host[0] . '.' . $host[1]);

}

二、在 config 的 components 配置中加入

'user' => [

'identityClass' => 'common\models\User',

'enableAutoLogin' => true,

'identityCookie' => ['name' => '_identity', 'httpOnly' => true, 'domain' => '.'.DOMAIN],

],

'session' => [

'cookieParams' => ['domain' => '.'.DOMAIN, 'lifetime' => 0],

'timeout' => 3600,

],

三、controller 中使用

//设置

Yii::$app->session['var']='value';

//使用

echo Yii::$app->session['var'];

//移除

unset(Yii::$app->session['var']);

四、测试

4.1 www.aaa.com 登陆

4.2 www.bbb.com session 依然有效果。

转载地址:http://trkdy.baihongyu.com/

你可能感兴趣的文章
【 Notes 】SOURCE LOCALIZATION PREVIEW
查看>>
【 Overview 】MEASUREMENT MODELS AND PRINCIPLES FOR SOURCE LOCALIZATION
查看>>
【 Notes 】TOA Measurement Model
查看>>
【 Overview 】ALGORITHMS FOR SOURCE LOCALIZATION
查看>>
【 Notes 】NLS ALGORITHMS of TOA - Based Positioning
查看>>
【 NLS 】Newton – Raphson Iteration Procedure of TOA - Based Positioning
查看>>
【 NLS 】Gauss-Netwon algorithm Iteration Procedure of TOA - Based Positioning
查看>>
【 NLS 】Steepest Descent Algorithm Iteration Procedure of TOA - Based Positioning
查看>>
【 Notes 】ML ALGORITHMS of TOA - Based Positioning
查看>>
【 ML 】Newton – Raphson Iteration Procedure of TOA - Based Positioning Simulation
查看>>
【 ML 】 Gauss – Newton Iteration Procedure of TOA - Based Positioning Simulation
查看>>
【 ML 】Steepest Descent Iteration Procedure of TOA - Based Positioning Simulation
查看>>
【 LLS 】Linear Approaches of TOA - Based Positioning
查看>>
【 MATLAB 】 LLS algorithm Simulation of TOA - Based Positioning
查看>>
【 MATLAB 】 WLLS algorithm Simulation of TOA - Based Positioning
查看>>
【 MATLAB】 Two-step WLS algorithm Simulation of TOA - Based Positioning
查看>>
【 MATLAB】Subspace algorithm Simulation of TOA - Based Positioning
查看>>
【 Notes 】WLLS Algorithm of TOA - Based Positioning (include the two - step WLS estimator)
查看>>
【 Notes 】Best linear unbiased estimator(BLUE) approach for time-of-arrival based localisation
查看>>
Heron's formula
查看>>