Skip to content

setSessionCookieTimeout and applyFirst #14677

@ibril15

Description

@ibril15

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFor errors / faults / flaws / inconsistencies etc.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions