Skip to content
Extraits de code Groupes Projets
Valider 37c5c074 rédigé par mattpiwik's avatar mattpiwik
Parcourir les fichiers

Fixes #1155 Cookie path can now be defined in config file

git-svn-id: http://dev.piwik.org/svn/trunk@1927 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 746f1585
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -122,6 +122,10 @@ login_cookie_name = piwik_auth
; login cookie expiration (30 days)
login_cookie_expire = 2592000
; The path on the server in which the cookie will be available on.
; Defaults to empty. See spec in http://curl.haxx.se/rfc/cookie_spec.html
login_cookie_path =
; email address that appears as a Sender in the password recovery email
; if specified, {DOMAIN} will be replaced by the current Piwik domain
login_password_recovery_email_address = "password-recovery@{DOMAIN}"
......@@ -191,6 +195,10 @@ cookie_name = piwik_visitor
; by default, the Piwik tracking cookie expires in 2 years
cookie_expire = 63072000
; The path on the server in which the cookie will be available on.
; Defaults to empty. See spec in http://curl.haxx.se/rfc/cookie_spec.html
cookie_path =
; variable name to track any campaign, for example CPC campaign
; Example: If a visitor first visits 'index.php?piwik_campaign=Adwords-CPC' then it will be counted as a campaign referer named 'Adwords-CPC'
campaign_var_name = piwik_campaign
......
......@@ -46,11 +46,12 @@ class Piwik_Cookie
*
* @param string cookie Name
* @param int The timestamp after which the cookie will expire, eg time() + 86400
* @param string The path on the server in which the cookie will be available on.
*/
public function __construct( $cookieName, $expire = null)
public function __construct( $cookieName, $expire = null, $path = null)
{
$this->name = $cookieName;
$this->path = $path;
$this->expire = $expire;
if(is_null($expire)
|| !is_numeric($expire)
......@@ -59,6 +60,7 @@ class Piwik_Cookie
$this->expire = $this->getDefaultExpire();
}
if($this->isCookieFound())
{
$this->loadContentFromCookie();
......@@ -139,7 +141,7 @@ class Piwik_Cookie
public function save()
{
$this->setP3PHeader();
$this->setCookie( $this->name, $this->generateContentString(), $this->expire);
$this->setCookie( $this->name, $this->generateContentString(), $this->expire, $this->path);
}
/**
......
......@@ -476,6 +476,16 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
{
return time() + Piwik_Tracker_Config::getInstance()->Tracker['cookie_expire'];
}
/**
* Returns cookie path
*
* @return string
*/
protected function getCookiePath()
{
return Piwik_Tracker_Config::getInstance()->Tracker['cookie_path'];
}
/**
* This methods tries to see if the visitor has visited the website before.
......@@ -509,7 +519,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
protected function recognizeTheVisitor()
{
$this->visitorKnown = false;
$this->setCookie( new Piwik_Cookie( $this->getCookieName(), $this->getCookieExpire() ) );
$this->setCookie( new Piwik_Cookie( $this->getCookieName(), $this->getCookieExpire(), $this->getCookiePath() ) );
/*
* Case the visitor has the piwik cookie.
......
......@@ -138,7 +138,8 @@ class Piwik_Login_Controller extends Piwik_Controller
$authCookieName = Zend_Registry::get('config')->General->login_cookie_name;
$authCookieExpiry = time() + Zend_Registry::get('config')->General->login_cookie_expire;
$cookie = new Piwik_Cookie($authCookieName, $authCookieExpiry);
$authCookiePath = Zend_Registry::get('config')->General->login_cookie_path;
$cookie = new Piwik_Cookie($authCookieName, $authCookieExpiry, $authCookiePath);
$cookie->set('login', $login);
$cookie->set('token_auth', $authResult->getTokenAuth());
$cookie->save();
......
......@@ -68,7 +68,8 @@ class Piwik_Login extends Piwik_Plugin
$authCookieName = Zend_Registry::get('config')->General->login_cookie_name;
$authCookieExpiry = time() + Zend_Registry::get('config')->General->login_cookie_expire;
$authCookie = new Piwik_Cookie($authCookieName, $authCookieExpiry);
$authCookiePath = Zend_Registry::get('config')->General->login_cookie_path;
$authCookie = new Piwik_Cookie($authCookieName, $authCookieExpiry, $authCookiePath);
$defaultLogin = 'anonymous';
$defaultTokenAuth = 'anonymous';
if($authCookie->isCookieFound())
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter