Gravatar for stangmuscle13@gmail.com

Question by sid, Oct 29, 2015 4:44 PM

System.Net.CookieException with third party js and coveo

Hi,

I have recently implemented coveo search page using sitecore and asp.net

My prototype works fine until I integrated that page in our existing web page. We have some third party Javascripts that creates some cookies which is used for some other purpose and we dont have any control on them. This is on our existing web pages.

Now when I integrate Coveo search page on to this web site, I'm seeing the following error.

**The 'Value'='{"XX":"http%3A%2F%2Fwww.XXXXX.com%2F","X":""}' part of the cookie is invalid.**
Source: System
   at System.Net.Cookie.VerifySetDefaults(CookieVariant variant, Uri uri, Boolean isLocalDomain, String localDomain, Boolean set_default, Boolean isThrow)
   at System.Net.CookieContainer.Add(Cookie cookie)
   at Coveo.Search.Api.Proxy.ProxyHttpHandler.CopyIncomingRequest(HttpRequest from, HttpWebRequest to)
   at Coveo.Search.Api.Proxy.ProxyHttpHandler.ReverseProxyRequest(HttpContext context)
   at Coveo.Search.Api.Proxy.ProxyHttpHandler.OnReverseProxyRequest(HttpContext context)
   at Coveo.SearchProvider.Rest.SitecoreRestHttpHandler.OnReverseProxyRequest(HttpContext p_Context)
   at Coveo.Search.Api.Proxy.ProxyHttpHandler.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I'm seeing this error when I have that particular cookie. When looking into it more, i found that in Coveo.Search.Api.Proxy.ProxyHttpHandler.CopyIncomingRequest is looping through all the existing cookies in the domain and adding them.

HttpWebRequest.CookieContainer.Add(cookie)

in here when its adding the cookie, and throwing the error. i think this is expecting an encoded value or something which we dont have any control on that cookie. When i delete that particular issue causing cookie, my coveo search page works fine. But we need that cookie in our existing website.

So is there a way to solve this issue? a setting or something on coveo side?

We dont have any issues with this cookies untill now and we dont want to change the value of cookie just because of this.

Thanks for all the help !!!

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Oct 29, 2015 4:56 PM

For me, it seems that it's more the .Net framework (System.Net.Cookie.VerifySetDefaults) that is refusing your cookie value, not Coveo even if the error is thrown because of Coveo looping through the cookies.

You might want to search how to control the verification of cookies in ASP.Net and the .Net framework through app.config or web.config configuration.

1 Reply
Gravatar for slangevin@coveo.com

Answer by Simon, Dec 29, 2015 6:29 AM

The issue here is due to the Search interface sending all cookies to the Search API. If a cookie is not repecting the .Net framework format, the Search API will fail.

Since several cookies are built by third parties on which you might not have control, a fix was made in the Coveo for Sitecore December 2015 package.

Cheers,
Simon

Ask a question