Authored by hf

code review by hf: fixes some bugs

@@ -129,7 +129,7 @@ class Helpers @@ -129,7 +129,7 @@ class Helpers
129 */ 129 */
130 public static function getShoppingKeyByCookie() 130 public static function getShoppingKeyByCookie()
131 { 131 {
132 - $cookie = isset($_COOKIE['_Spk']) ? $_COOKIE['_Spk'] : ''; 132 + $cookie = isset($_COOKIE['_SPK']) ? $_COOKIE['_SPK'] : '';
133 133
134 return $cookie; 134 return $cookie;
135 } 135 }
@@ -71,7 +71,7 @@ class HomeModel @@ -71,7 +71,7 @@ class HomeModel
71 71
72 /** 72 /**
73 * 设置选择的频道保存到浏览器COOKIE 73 * 设置选择的频道保存到浏览器COOKIE
74 - * (已废弃,改成JS设置) 74 + * (已废弃,改成JS设置)
75 * 75 *
76 * @param string $cookie 76 * @param string $cookie
77 * @return void 77 * @return void
@@ -456,8 +456,8 @@ class IndexController extends AbstractAction @@ -456,8 +456,8 @@ class IndexController extends AbstractAction
456 $result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey); 456 $result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey);
457 457
458 // 设置加入购物车凭证到客户端浏览器 458 // 设置加入购物车凭证到客户端浏览器
459 - if (!$shoppingKey && isset($result['data']['shopping_key'])) {  
460 - $this->setCookie('_Spk', $result['data']['shopping_key']); 459 + if (empty($shoppingKey) && isset($result['data']['shopping_key'])) {
  460 + $this->setCookie('_SPK', $result['data']['shopping_key'], time() + 86400 * 360);
461 } 461 }
462 } 462 }
463 463
@@ -77,6 +77,7 @@ class LoginController extends AbstractAction @@ -77,6 +77,7 @@ class LoginController extends AbstractAction
77 // 清除客户端 77 // 清除客户端
78 $this->setCookie('_UID', ''); 78 $this->setCookie('_UID', '');
79 $this->setCookie('_TOKEN', ''); 79 $this->setCookie('_TOKEN', '');
  80 + $this->setCookie('_SPK', '');
80 // 清除服务端会话 81 // 清除服务端会话
81 $this->setSession('_TOKEN', ''); 82 $this->setSession('_TOKEN', '');
82 83