November Happy Hour will be moved to Thursday December 5th.

Disable cookies

Vote:
 

Hi there,

We are trying to disable the following cookies:

We added the following code:

        protected void Application_EndRequest()

        {
            try
            {
                if (System.Web.HttpContext.Current != null)
                {
                    System.Web.HttpContext.Current.Response.Cookies.Remove("EPiForm_BID");

System.Web.HttpContext.Current.Response.Cookies.Remove("EPiForm_VisitorIdentifier");
                }
            }
            catch (Exception)
            {
                //Do nothing, just don't take down the site
            }
        }

To our Global.asax.cs file.

However the cookies are still being loaded.

The cookies in question are:

EPiForm_BID

EPiForm_VisitorIdentifier

Any tips on how we can achieve this?

#210584
Nov 28, 2019 15:24
Vote:
 

As those cookies are related to forms, you should be able to remove them by setting visitorSubmitTimeout to -1 in your forms.config file.

#210585
Nov 28, 2019 15:39
Vote:
 

Thanks for your suggestion. I just tried it on my localhost instance and they are still being loaded despite setting visitorSubmitTimeout to -1. 

#210587
Nov 28, 2019 15:50
Vote:
 

I believe the cookies are .EPiForm_BID and .EPiForm_VisitorIdentifier, note the beginning dot 

#210588
Nov 28, 2019 16:02
Vote:
 

Hmm. Interesting. I've just given it a try and I've found that both Quan's suggestion of adding the leading dot and my suggestion of setting visitorSubmitTimeout to -1 successfully prevent the cookies from being set though, if those cookies already exist then they won't be removed by either method. Did you clear your cookies before giving it a try?

It's also worth noting that you'd need an app pool recycle after changing the value in the forms.config as, to the best of my knowledge, those values are read in on initialization rather than each time they're needed.

#210590
Nov 28, 2019 16:39
Vote:
 

Strange. I am testing this using a local instance of our website on my PC. Using visual studio I am building it each time and it is running under localhost.

How do I carry out an app pool recycle ? Or is that relevant at all for the way I am testing it?

#210611
Nov 29, 2019 14:48
Vote:
 

As a test I tried a different browser (Firefox) and the cookie was not loaded (at the moment, due to the tests I have been doing I am only removing ".EPiForm_BID"). 

I then as a test also uncommented my code in order to remove ".EPiForm_VisitorIdentifier" but when I reloaded the website in Firefox, the cookie was still there. Even if I delete the cookie manually in the browser. So it seems this "app pool recycle" might be the issue but unsure how to do this when you don't have a dedicated IIS Server. I am using whatever comes with Visual Studio (and it all seems to be happening in the background). Any ideas?

#210613
Nov 29, 2019 15:03
Vote:
 

Hi epiNew,

Paul is referring to the case where you run your site in IIS and not in IIS Express (what is used by default when you run the app from Visual Studio IF you have not configured the project to use IIS). So I'm making the assumtion that you use IIS Express, so then there is no way to do application pool recycle (besides just website restart is usually enough instead of application pool recycle).

Also how IIS Express behaves really depends on your Visual Studio settings like 'edit and continue' option. When IIS Express is running you should see that icon in your Windows task bar, blue-ish icon, right click and you can see what sites are running and then you could stop the site and re-run the website project from Visual Studio - so that way you can make sure it has your latest configuration changes.

#210616
Nov 30, 2019 9:14
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.