I am working with cookies and I happened to create it using JavaScript ,but when I try to expire that cookie after my process is completed,using C# code behind file ,there I am unable to find the specified Cookie??
What could be the reason for this?? I think cookies created in JavaScript are not accessible/Visible using C# ...? Is that true??
Here is my code for creating cookie in JS
var expiryDate = new Date();
expiryDate.setTime(expiryDate.setDate(expiryDate.getDate() + 1)); // 365 days
document.cookie = "ReferedCookie=" + "clientId=" + UserGuid + "&productId=" + productId + "&Token=" + token + ";" + "expires=" + expiryDate.toGMTString() + ";";
and here is my C# code for finding and expiring cookie
public void DeleteCookie(string Name)
{
if (System.Web.HttpContext.Current.Request.Cookies["ReferedCookie"] != null)
{
HttpCookie myCookie = new HttpCookie(Name);
myCookie.Expires = DateTime.Now.AddDays(-5d);
System.Web.HttpContext.Current.Response.Cookies.Add(myCookie);
}
}
Thanks in advance.