Problems updating Google Translate cookie in Chrome Problems updating Google Translate cookie in Chrome google-chrome google-chrome

Problems updating Google Translate cookie in Chrome


Check the response headers, but I do not believe that the cookie will not be sent in the request when your address is localhost. So, with your logic the preference will update each time since the request has no cookie present.

An HttpResponse will not send back the cookies that came in the request, it only adds cookies that you mean to set in the response. So when you are testing in the beta site a request comes in with a cookie after it has been set, and will call the code in the else condition. The HttpCookieCollection.Set(...) method does not add a cookie, only updates one that exists in the collection already. I would change the code to read like this:

private void AddOrSetCookie(HttpCookie cookie, String cookieName){    if (System.Web.HttpContext.Current.Request.Cookies[cookieName] == null        || System.Web.HttpContext.Current.Request.Cookies[cookieName].Value != cookie.Value )    {        System.Web.HttpContext.Current.Response.Cookies.Add(cookie);    }}


please don't use cookies - that is why html5 includes local storage

more about local storage: http://www.html5rocks.com/en/tutorials/offline/storage

and for your scenario: http://www.codeguru.com/csharp/.net/two-ways-of-passing-html5-web-storage-data-to-asp.net.htm

by the way: these features are also supported for IE8!!! (as shown here: http://caniuse.com/#search=local%20storage)