AddProductToCompareList(int productId)
{
var oldProductIds = GetComparedProductIds();
var newProductIds = new List<int>();
newProductIds.Add(productId);
foreach (int oldProductId in oldProductIds)
if (oldProductId != productId)
newProductIds.Add(oldProductId);
var compareCookie = _httpContext.Request.Cookies.Get(COMPARE_PRODUCTS_COOKIE_NAME);
if (compareCookie == null)
{
compareCookie = new HttpCookie(COMPARE_PRODUCTS_COOKIE_NAME);
compareCookie.HttpOnly = true;
}
compareCookie.Values.Clear();
int i = 1;
foreach (int newProductId in newProductIds)
{
compareCookie.Values.Add("CompareProductIds", newProductId.ToString());
if (i == _catalogSettings.CompareProductsNumber)
break;
i++;
}
compareCookie.Expires = DateTime.Now.AddDays(10.0);
_httpContext.Response.Cookies.Set(compareCookie);
}
if we have empty compare list and add one product to this list we are not be able to read compareCookie on client site(JS) because of the following string.
compareCookie.HttpOnly = true;
please remove this string.
thank you in advance.