Esempio n. 1
0
        /// <summary>
        /// 设置用户的浏览记录
        /// </summary>
        /// <param name="productSysNo"></param>
        public static void SetCustomerBrowserHistory(int productSysNo)
        {
            // 如果product已经存在于cookie中,就不用更新了
            // 更新Cookie
            // 更新Session

            string cookie = CookieUtil.GetDESEncryptedCookieValue(CookieUtil.Cookie_BrowseHistory);

            string newCookie = productSysNo.ToString();

            if (cookie != null)
            {
                string[] productArray = cookie.Split(',');

                int index = 0; // 新的字符串的个数
                for (int i = 0; i < productArray.Length; i++)
                {
                    if (productArray[i] != productSysNo.ToString())
                    {
                        newCookie += ",";
                        try
                        {
                            Convert.ToInt32(productArray[i]);
                        }
                        catch
                        {
                            //出错重置为当前product
                            newCookie = productSysNo.ToString();
                            break;
                        }
                        newCookie += productArray[i];
                        index++;
                    }

                    if (index == 9)
                    {
                        break;
                    }
                }
            }
            CookieUtil.SetDESEncryptedCookie(CookieUtil.Cookie_BrowseHistory, newCookie, DateTime.MaxValue);
        }
Esempio n. 2
0
        private void SaveCart(Hashtable ht)
        {
            if (ht == null || ht.Count == 0)
            {
                CookieUtil.SetDESEncryptedCookie("cart", "", DateTime.MaxValue);
                return;
            }
            int           i  = 0;
            StringBuilder sb = new StringBuilder(200);

            foreach (CartInfo item in ht.Values)
            {
                if (i != 0)
                {
                    sb.Append(";");
                }
                sb.Append(item.ProductSysNo.ToString() + "," + item.Quantity.ToString() + "," + item.ExpectQty.ToString());
                i++;
            }
            CookieUtil.SetDESEncryptedCookie("cart", sb.ToString(), DateTime.MaxValue);
        }
Esempio n. 3
0
 /// <summary>
 /// 清除用户的所有cookie
 /// </summary>
 public static void ClearCustomerBrowserHistoryProductsAll()
 {
     CookieUtil.SetDESEncryptedCookie(CookieUtil.Cookie_BrowseHistory, String.Empty);
 }