@ibril15 opened this Issue on July 19th 2019

Hi Everyone,

I have the JS tracker code that looks something like this:

var _paq = _paq || [];
_paq.push(['setSessionCookieTimeout', 7200]);
_paq.push(['trackPageView']);

var matomoload = (function () {
  var u = "//" + g_strMatomoURL + "/";
  _paq.push(['setTrackerUrl', u + 'piwik.php']);
  _paq.push(['setSiteId', g_strMatomoSiteID]);
  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 + 'piwik.js'; 
  s.parentNode.insertBefore(g, s);
});
if (window.addEventListener) { window.addEventListener("load", matomoload, false); }
else if (window.attachEvent) { window.attachEvent("onload",matomoload); }

Despite the "setSessionCookieTimeout" call, the _pk_ses cookie is created with a 30 minute expiration (as per the default). Since this is not a SPA, every page keeps updating the cookie with the 30 minute expiration. However, if I add "setSessionCookieTimeout" to the applyFirst array in piwik.js, then the cookie is created with the 2 hour expiration as desired. Is that a bug, or do I misunderstand the intent of setSessionCookieTimeout and applyFirst?

On a related note, I'm struggling to understand what expiration of _pk_ses actually controls. I changed visit_standard_length to 2 hours in the config.ini.php file and that seems to do what I expect without the JS setSessionCookieTimeout call. Even if I delete the _pk_ses cookie, the original visit is still continued on the next page navigation. In case it matters, I also have trust_visitors_cookies = 1.

Thanks a lot.

-Igor

@tsteur commented on July 20th 2019 Member

Thanks for letting us know, created a PR 👍

@ibril15 commented on July 22nd 2019

Great, thank you! Do you have a sense of what exactly won't work correctly in my setup if visit_standard_length is 2 hours, but the session cookie timeout is 30 minutes?

@tsteur commented on July 22nd 2019 Member

Good question, I think it would increase the visit count more often and possibly play up a little bit with the "last known referrer" but not sure how much that would actually effect it.

This Issue was closed on August 1st 2019
Powered by GitHub Issue Mirror