Authored by xiaowei

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

@@ -17,9 +17,9 @@ class LoginController extends AbstractAction @@ -17,9 +17,9 @@ class LoginController extends AbstractAction
17 */ 17 */
18 public function indexAction() 18 public function indexAction()
19 { 19 {
20 - // 设置登录有效时间30分钟, 防机器刷  
21 - $this->setSession('_LOGIN_EXPIRE', time() + 1800);  
22 - 20 + // 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie
  21 + $this->setCookie('LE' . md5('_LOGIN_EXPIRE'), time() + 1800);
  22 +// $this->setSession('_LOGIN_EXPIRE', time() + 1800);
23 // 清除客户端 23 // 清除客户端
24 $this->setCookie('_UID', ''); 24 $this->setCookie('_UID', '');
25 $this->setCookie('_TOKEN', ''); 25 $this->setCookie('_TOKEN', '');
@@ -54,8 +54,9 @@ class LoginController extends AbstractAction @@ -54,8 +54,9 @@ class LoginController extends AbstractAction
54 */ 54 */
55 public function internationalAction() 55 public function internationalAction()
56 { 56 {
57 - // 设置登录有效时间30分钟, 防机器刷  
58 - $this->setSession('_LOGIN_EXPIRE', time() + 1800); 57 + // 设置登录有效时间30分钟, 防机器刷,cache不稳定,改为cookie
  58 + $this->setCookie('LE' . md5('_LOGIN_EXPIRE'), time() + 1800);
  59 +// $this->setSession('_LOGIN_EXPIRE', time() + 1800);
59 60
60 $refer = $this->get('refer'); 61 $refer = $this->get('refer');
61 if (!empty($refer)) { 62 if (!empty($refer)) {
@@ -132,8 +133,10 @@ class LoginController extends AbstractAction @@ -132,8 +133,10 @@ class LoginController extends AbstractAction
132 } 133 }
133 134
134 /* 设置登录有效时间30分钟, 防机器刷 */ 135 /* 设置登录有效时间30分钟, 防机器刷 */
135 - $expire = $this->getSession('_LOGIN_EXPIRE'); 136 + $expire = $this->getCookie('LE' . md5('_LOGIN_EXPIRE'));
  137 +// $expire = $this->getSession('_LOGIN_EXPIRE');
136 if (empty($expire) || $expire < time()) { 138 if (empty($expire) || $expire < time()) {
  139 + $data = array('code' => 400, 'message' => '页面停留时间过长,请刷新页面', 'data' => '');
137 break; 140 break;
138 } 141 }
139 142
@@ -148,7 +151,8 @@ class LoginController extends AbstractAction @@ -148,7 +151,8 @@ class LoginController extends AbstractAction
148 $refer = $this->getCookie('refer'); 151 $refer = $this->getCookie('refer');
149 if (empty($refer)) { 152 if (empty($refer)) {
150 $refer = SITE_MAIN . '/?go=1'; 153 $refer = SITE_MAIN . '/?go=1';
151 - } else { 154 + }
  155 + else {
152 $refer = rawurldecode($refer); 156 $refer = rawurldecode($refer);
153 } 157 }
154 $data['data']['session'] = Helpers::syncUserSession($data['data']['uid']); 158 $data['data']['session'] = Helpers::syncUserSession($data['data']['uid']);
@@ -158,7 +162,8 @@ class LoginController extends AbstractAction @@ -158,7 +162,8 @@ class LoginController extends AbstractAction
158 $this->setCookie('_TOKEN', $token); 162 $this->setCookie('_TOKEN', $token);
159 $this->setSession('_TOKEN', $token); 163 $this->setSession('_TOKEN', $token);
160 $this->setSession('_LOGIN_UID', $data['data']['uid']); 164 $this->setSession('_LOGIN_UID', $data['data']['uid']);
161 - } while (false); 165 + }
  166 + while (false);
162 167
163 $this->echoJson($data); 168 $this->echoJson($data);
164 } 169 }
@@ -214,13 +219,14 @@ class LoginController extends AbstractAction @@ -214,13 +219,14 @@ class LoginController extends AbstractAction
214 219
215 //判定是否需要绑定手机号 220 //判定是否需要绑定手机号
216 if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') { 221 if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
217 - $this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay')));//'nickname' => $realName 222 + $this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay'))); //'nickname' => $realName
218 } 223 }
219 224
220 $refer = $this->getCookie('refer'); 225 $refer = $this->getCookie('refer');
221 if (empty($refer)) { 226 if (empty($refer)) {
222 $refer = SITE_MAIN . '/?go=1'; 227 $refer = SITE_MAIN . '/?go=1';
223 - } else { 228 + }
  229 + else {
224 $refer = rawurldecode($refer); 230 $refer = rawurldecode($refer);
225 } 231 }
226 232
@@ -230,7 +236,8 @@ class LoginController extends AbstractAction @@ -230,7 +236,8 @@ class LoginController extends AbstractAction
230 $this->setSession('_LOGIN_UID', $result['data']['uid']); 236 $this->setSession('_LOGIN_UID', $result['data']['uid']);
231 $this->setCookie('_TOKEN', $token); 237 $this->setCookie('_TOKEN', $token);
232 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer)); 238 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
233 - } else { 239 + }
  240 + else {
234 $this->go($refer); 241 $this->go($refer);
235 } 242 }
236 } 243 }
@@ -252,13 +259,14 @@ class LoginController extends AbstractAction @@ -252,13 +259,14 @@ class LoginController extends AbstractAction
252 259
253 //判定是否需要绑定手机号 260 //判定是否需要绑定手机号
254 if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') { 261 if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
255 - $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq')));//'nickname' => $partnerInfo['nickname'] 262 + $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq'))); //'nickname' => $partnerInfo['nickname']
256 } 263 }
257 264
258 $refer = $this->getCookie('refer'); 265 $refer = $this->getCookie('refer');
259 if (empty($refer)) { 266 if (empty($refer)) {
260 $refer = SITE_MAIN . '/?go=1'; 267 $refer = SITE_MAIN . '/?go=1';
261 - } else { 268 + }
  269 + else {
262 $refer = rawurldecode($refer); 270 $refer = rawurldecode($refer);
263 } 271 }
264 272
@@ -268,7 +276,8 @@ class LoginController extends AbstractAction @@ -268,7 +276,8 @@ class LoginController extends AbstractAction
268 $this->setSession('_LOGIN_UID', $result['data']['uid']); 276 $this->setSession('_LOGIN_UID', $result['data']['uid']);
269 $this->setCookie('_TOKEN', $token); 277 $this->setCookie('_TOKEN', $token);
270 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer)); 278 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
271 - } else { 279 + }
  280 + else {
272 $this->go($refer); 281 $this->go($refer);
273 } 282 }
274 } 283 }
@@ -290,13 +299,14 @@ class LoginController extends AbstractAction @@ -290,13 +299,14 @@ class LoginController extends AbstractAction
290 } 299 }
291 //判定是否需要绑定手机号 300 //判定是否需要绑定手机号
292 if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') { 301 if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
293 - $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina')));//'nickname' => $partnerInfo['screen_name'] 302 + $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina'))); //'nickname' => $partnerInfo['screen_name']
294 } 303 }
295 304
296 $refer = $this->getCookie('refer'); 305 $refer = $this->getCookie('refer');
297 if (empty($refer)) { 306 if (empty($refer)) {
298 $refer = SITE_MAIN . '/?go=1'; 307 $refer = SITE_MAIN . '/?go=1';
299 - } else { 308 + }
  309 + else {
300 $refer = rawurldecode($refer); 310 $refer = rawurldecode($refer);
301 } 311 }
302 312
@@ -306,7 +316,8 @@ class LoginController extends AbstractAction @@ -306,7 +316,8 @@ class LoginController extends AbstractAction
306 $this->setSession('_LOGIN_UID', $result['data']['uid']); 316 $this->setSession('_LOGIN_UID', $result['data']['uid']);
307 $this->setCookie('_TOKEN', $token); 317 $this->setCookie('_TOKEN', $token);
308 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer)); 318 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
309 - } else { 319 + }
  320 + else {
310 $this->go($refer); 321 $this->go($refer);
311 } 322 }
312 } 323 }