Piwik cookie settings

Is there a way to set how long the cookie set by piwik lasts?

We are not allowed to use permanent cookies.

Thanks

From the next release 0.2.27 cookies are set for 2 years by default.

Can that be changed to a shorter time period?

that would be quite easy. can you please create a ticket? on dev.piwik.org

Does setting the cookie expiration option to zero make the cookies that piwik uses not persistent? Would doing this affect statistics in any negative way?

piwik uses setcookie php function.
according to documentation: http://php.net/setcookie

If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

test to set

[Tracker]
cookie_expire = 0

and please report if it does behave like a session cookie.

Matt,
Thanks for the response. I will test the setting when I get a chance to upgrade to the latest piwik version. Do you have any advice on the second half of my question, regarding how this will affect the statistics that piwik gathers? Will it cause more unique visitors to be reported because the cookie won’t be there if they close and reopen the site in their browser?

Thanks,
-Tim

[quote=matthieu @ Feb 26 2009, 03:45 PM]piwik uses setcookie php function.
according to documentation: http://php.net/setcookie

If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

test to set

[Tracker]
cookie_expire = 0

and please report if it does behave like a session cookie.[/quote]

Matt,
After upgrading Piwik and configuring cookie_expire to zero (0), I discovered that the cookie is set with an expiration date matching the page load time. This effectively makes the cookie expire when the user closes their browser, but I believe it isn’t quite the same as a cookie that has no expiration value at all. Wikipedia says the following from http://en.wikipedia.org/wiki/HTTP_cookie#Implementation:

The cookie setter can specify a deletion date, in which case the cookie will be removed on that date. If the cookie setter does not specify a date, the cookie is removed once the user quits his or her browser. As a result, specifying a date is a way for making a cookie survive across sessions. For this reason, cookies with an expiration date are called persistent.

Since there is in fact an expiration set in the piwik cookie (even with cookie_expire set to zero), eventhough it’s a date that has past, I believe that the cookie still qualifies as “persistent”. Could Piwik could be modified to not set a cookie expiration when cookie_expire is set to zero? Or perhaps some other configuration variable? Should I submit a ticket? Maybe I can look at the code and submit a diff?

Thanks,
-Tim

[quote=matthieu @ Feb 26 2009, 03:45 PM]piwik uses setcookie php function.
according to documentation: http://php.net/setcookie

If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

test to set

[Tracker]
cookie_expire = 0

and please report if it does behave like a session cookie.[/quote]

i would tend to trust php.net that says "If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes). "

if the cookie closes when browser closes, then cookie is not persistent right?

If the cookie is not set to persistent (such as this), would Piwik then count a user who leaves and comes back as a unique visitor, or would it simply issue them a new cookie and count them as already visited (possibly using the heuristic that is described for non-cookie users)?

I am also very interested in this. Due to the nature of the site, I need to make the standard visit time excessively long, so in order to accurately track the number of visits, I need to have some way to ‘end’ a visit before the time expires. My thought was to do this by deleting the cookie, since I’ve created a plugin that effectively tracks unique visitors anyway (through a username). However, this has failed to generate a new visitor_idcookie value for a returning visitor after the expire time of the cookie has passed and even after the browser has been restarted.
In my case, setting the cookie expire time to zero does generate a new id every day, but otherwise seems uncontrollable.