Fixes #17417 by setting the cookie domain (configCookieDomain) even when cookies are disabled.
Also checks whether setCookie is able to successfully create a cookie and if not, log a console message for visibility.
Tested locally via the test-examples repo, after adding the following code:
_paq.push(['requireCookieConsent']); _paq.push(["setCookieDomain", ".matomotestexamples"]);
And viewing the page on the
www.matomotestexamples URL (both mapped via /etc/hosts).
rememberConsentGiven() creates cookies (only one set, for the www.matomotestexamples domain). On this branch, the cookies are not created and the message "There was an error setting the cookie" is in the console log. I'm not sure why it works in one but not the other...
@diosmosis I think that issue is because you are trying to set cookies on a top level domain (.matomotestexamples). Other than that your results are as I expect.
@justinvelluppillai would you know why it works without your changes and sets the cookie correctly, but doesn't w/ the changes? I don't see anything in the code that could cause this, but it is reproducible.
@diosmosis it used to set the cookie on the wrong domain, ignoring the setCookieDomain directive. On the new it doesn't ignore the setCookieDomain directive and tries to set the cookie on the domain specified, but you have specified a top level domain on which it can't set a cookie, therefore it doesn't set the cookie on the new. Once you change the test domains to for example www.matomotestexamples.matomo and .matomotestexamples.matomo it will work
@justinvelluppillai fyi, there are still some JSLint errors it seems
Passing js tests now @diosmosis - took me a few iterations of adding semicolons to get it through the jslint-ing.