I am using Sitecore 10
with JSS
Angular
app, I need to set site language cookie
{{mysite}}#lang to be HttpOnly so I have created the HttpRequest
pipeline processor
.
public class CookieProcessor : HttpRequestProcessor
{
public List<string> Sites { get; set; }
public CookieProcessor()
{
Sites = new List<string>();
}
public override void Process(HttpRequestArgs args)
{
if (!Sites.Contains(Sitecore.Context.Site.Name))
return;
var cookie = HttpContext.Current.Request.Cookies[Sitecore.Context.Site.Name+"#lang"];
if (cookie != null)
{
cookie.HttpOnly = true;
HttpContext.Current.Response.Cookies.Add(cookie);
}
}
}
and this the patch
config file.
<sitecore>
<pipelines>
<httpRequestBegin>
<processor type="Maqta.Project.Website.CookieProcessor,Maqta.Project.Website"
patch:after="processor[@type='Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel']" resolve="true">
</processor>
</httpRequestBegin>
</pipelines>
</sitecore>
This change works fine for the English version but when I navigate to the Arabic version, it is set correctly first but gets overwritten after the page is fully loaded.
Maybe this happens when the cookie value is set to be "ar" instead of "en"
so any idea when cookie value set to be "ar" and if there are pipelines run after this??
Note: also I have tried to use this processor
processor[@type='Sitecore.Pipelines.HttpRequest.LanguageResolver, Sitecore.Kernel']
instead of ItemResolver but still the same issue