Authored by xiaowei

登录页面时间停留过长优化

... ... @@ -17,9 +17,9 @@ class LoginController extends AbstractAction
*/
public function indexAction()
{
// 设置登录有效时间30分钟, 防机器刷
$this->setSession('_LOGIN_EXPIRE', time() + 1800);
// 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie
$this->setCookie('LE' . md5('_LOGIN_EXPIRE'), time() + 1800);
// $this->setSession('_LOGIN_EXPIRE', time() + 1800);
// 清除客户端
$this->setCookie('_UID', '');
$this->setCookie('_TOKEN', '');
... ... @@ -54,8 +54,9 @@ class LoginController extends AbstractAction
*/
public function internationalAction()
{
// 设置登录有效时间30分钟, 防机器刷
$this->setSession('_LOGIN_EXPIRE', time() + 1800);
// 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie
$this->setCookie('LE' . md5('_LOGIN_EXPIRE'), time() + 1800);
// $this->setSession('_LOGIN_EXPIRE', time() + 1800);
$refer = $this->get('refer');
if (!empty($refer)) {
... ... @@ -83,7 +84,7 @@ class LoginController extends AbstractAction
// 清除服务端会话
$this->setSession('_TOKEN', '');
$this->setSession('_LOGIN_UID', '');
// 清除客户端
$this->setCookie('_UID', '');
$this->setCookie('_TOKEN', '');
... ... @@ -132,8 +133,10 @@ class LoginController extends AbstractAction
}
/* 设置登录有效时间30分钟, 防机器刷 */
$expire = $this->getSession('_LOGIN_EXPIRE');
$expire = $this->getCookie('LE' . md5('_LOGIN_EXPIRE'));
// $expire = $this->getSession('_LOGIN_EXPIRE');
if (empty($expire) || $expire < time()) {
$data = array('code' => 400, 'message' => '页面停留时间过长,请刷新页面', 'data' => '');
break;
}
... ... @@ -148,7 +151,8 @@ class LoginController extends AbstractAction
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
} else {
}
else {
$refer = rawurldecode($refer);
}
$data['data']['session'] = Helpers::syncUserSession($data['data']['uid']);
... ... @@ -158,7 +162,8 @@ class LoginController extends AbstractAction
$this->setCookie('_TOKEN', $token);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $data['data']['uid']);
} while (false);
}
while (false);
$this->echoJson($data);
}
... ... @@ -214,13 +219,14 @@ class LoginController extends AbstractAction
//判定是否需要绑定手机号
if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay')));//'nickname' => $realName
$this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay'))); //'nickname' => $realName
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
} else {
}
else {
$refer = rawurldecode($refer);
}
... ... @@ -230,7 +236,8 @@ class LoginController extends AbstractAction
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
} else {
}
else {
$this->go($refer);
}
}
... ... @@ -252,13 +259,14 @@ class LoginController extends AbstractAction
//判定是否需要绑定手机号
if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq')));//'nickname' => $partnerInfo['nickname']
$this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq'))); //'nickname' => $partnerInfo['nickname']
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
} else {
}
else {
$refer = rawurldecode($refer);
}
... ... @@ -268,7 +276,8 @@ class LoginController extends AbstractAction
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
} else {
}
else {
$this->go($refer);
}
}
... ... @@ -290,13 +299,14 @@ class LoginController extends AbstractAction
}
//判定是否需要绑定手机号
if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina')));//'nickname' => $partnerInfo['screen_name']
$this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina'))); //'nickname' => $partnerInfo['screen_name']
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
} else {
}
else {
$refer = rawurldecode($refer);
}
... ... @@ -306,7 +316,8 @@ class LoginController extends AbstractAction
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
} else {
}
else {
$this->go($refer);
}
}
... ...