Skip to content
Advertisement

Application Insights secure cookies

Hi I have a WebApp on which I am using Application Insights with the Javascript SDK. In the Chrome developer tools I see that there are 2 cookier, ai_user and ai_session, which are not secure. I have already changed the code in my app to have all other cookies as secure, but I can’t manage to have these ones also as secure. I posted a question directly on the Microsoft Application Insights documentation page and they told me to update the script, which led to an error that I fixed, but still the cookies are not secure (Details are in my comment from the comment section of the link above, which is presently the first top comment in the section). I asked them back but they no longer replied to me.

My current code to initialize application insights is

JavaScript

I had to add the ‘url’ property otherwise it was pointing to “localhost/CDN_PATH” which is of course wrong.

Update: I also found this issue on GitHub which seems to be exactly what I am looking for but it’s still open…

Advertisement

Answer

Ok, since I have found no better way to do this, I have decompressed the source code of ApplicationInsights (to be found here and changed line 254 like that:

JavaScript

(in short I have added the ‘secure;’ string to the existing string). I have then re-compressed the js code and changed my AI initialization script like so:

JavaScript

Now it works (cookies are now set as secure), but I am still open to better approaches. This would probably mean to fork the corresponding GitHub repository, I will maybe try that later.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement