Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setSessionCookieTimeout and applyFirst #14677

Closed
ibril15 opened this issue Jul 19, 2019 · 3 comments · Fixed by #14678
Closed

setSessionCookieTimeout and applyFirst #14677

ibril15 opened this issue Jul 19, 2019 · 3 comments · Fixed by #14678
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@ibril15
Copy link

ibril15 commented Jul 19, 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 tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Jul 20, 2019
@tsteur tsteur added this to the 3.12.0 milestone Jul 20, 2019
@tsteur
Copy link
Member

tsteur commented Jul 20, 2019

Thanks for letting us know, created a PR 👍

@ibril15
Copy link
Author

ibril15 commented Jul 22, 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
Copy link
Member

tsteur commented Jul 22, 2019

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.

@mattab mattab modified the milestones: 3.13.0, 3.12.0 Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants