The method 'setSecureCookie' was not found... (3.2.0)

Hello community,
I tried to use the new setSecureCookie method for https only sites, but can’t get it working.
First there is a difference between the API documentation and piwik.js:
API Doc: setSecureCookies( book )
piwik.js: setSecureCookie( bool ), default = false

So I assumed typos and added the second version to my tracking code:

var _paq = _paq || []; 
 _paq.push(['setVisitorCookieTimeout', '604800']); 
 _paq.push(['setSecureCookie', true]);
 _paq.push(['trackPageView']);
 _paq.push(['enableLinkTracking']);
 (function() { var u="https://piwik.example.com/";
_paq.push(['setTrackerUrl', u+'js/']); _paq.push(['setSiteId', 123]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'js/'; s.parentNode.insertBefore(g,s); })();

But it didn’t work and the Developer Console showed the error:
The method ‘setSecureCookie’ was not found in “_paq” variable

Did I get something completely wrong or is it a bug?

Thank you very much in advance!

Hi @Anoia
Thank for the report, there are indeed several issues with setSecureCookie, as it wasn’t properly tested.

  1. we’ve fixed the bug in our documentation in Fix typo in setSecureCookie by mattab · Pull Request #214 · piwik/developer-documentation · GitHub

  2. the piwik.js setSecureCookie actually does not work anyway, as you found out. Could you please try this Pull request: JS Tracker: make setSecureCookie work by mattab · Pull Request #12355 · piwik/piwik · GitHub
    in particular you can replace your piwik/piwik.js by this file: https://raw.githubusercontent.com/piwik/piwik/setSecureCookie/piwik.js

Are you then successful forcing secure cookies for Piwik cookies?

Would be great if you could comment on the Pull request.
Thanks,

Hi @matthieu

thank you very much for the superfast fix!

I installed the 3 files from the Pull request in my Piwik Test Environment and it works.
With the tracking code above, the pk_ Cookies Details show now “Send for: Encrypted connections only”

Verified in Chrome 62 and Firefox ESR 52. There seems to be no way to view theDetaill in IE, but then - nobody can complain about it. :smiley:

Many thanks again for your efforts!