diff --git a/htdocs/core/class/cookie.class.php b/htdocs/core/class/cookie.class.php
index 16191188195876c4324ab981bb0557b0aee189fd..86e96912762c88f997db902ae1179756c3d80250 100644
--- a/htdocs/core/class/cookie.class.php
+++ b/htdocs/core/class/cookie.class.php
@@ -109,7 +109,7 @@ class DolCookie
 		$this->myExpire = $expire;
 		$this->myPath = $path;
 		$this->myDomain = $domain;
-		$this->mySsecure = $secure;
+		$this->mySecure = $secure;
 
 		//print 'key='.$this->myKey.' name='.$this->myCookie.' value='.$this->myValue.' expire='.$this->myExpire;
 
diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php
index c403cd06347b0b1c0312a0bdf479271c18e911f0..2a941c3a3ed938f36c33a04be1b0a3104bab5445 100644
--- a/htdocs/lib/security.lib.php
+++ b/htdocs/lib/security.lib.php
@@ -84,7 +84,6 @@ function dol_loginfunction($langs,$conf,$mysoc)
 	if ( preg_match('/^([^.]+)\/htdocs\//i', realpath($_SERVER["SCRIPT_FILENAME"]), $regs))	$realpath = isset($regs[1])?$regs[1]:'';
 
 	// Set cookie for timeout management
-	// FIXME le cookie n'est pas créé la première fois
 	$sessiontimeout='DOLSESSTIMEOUT_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath);
 	if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0);
 
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 5ab9cd93f37e4c52b96494f6290008e2bd0b991c..0226a1d967c0722ceacaf81ebc9332d93e14db4a 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -548,7 +548,7 @@ if (! defined('NOLOGIN'))
 			include_once(DOL_DOCUMENT_ROOT."/core/class/cookie.class.php");
 
 			$entity = $_SESSION["dol_login"].'|'.$_POST["entity"];
-			$entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);
+			$entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath);
 			// TTL : is defined in the config page multicompany
 			$ttl = (! empty($conf->global->MAIN_MULTICOMPANY_COOKIE_TTL) ? $conf->global->MAIN_MULTICOMPANY_COOKIE_TTL : time()+60*60*8 );
 			// Cryptkey : will be created randomly in the config page multicompany
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index 1280f92287b8d63d1de8d11acc1e0406aa8c5e0e..997d7d346202ece4e31eecaea8b154f8eadd91c1 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -279,7 +279,11 @@ if (! defined('NOREQUIREDB'))
 	}
 	else
 	{
-		$entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"]);
+		// Add real path in session name
+		$realpath='';
+		if ( preg_match('/^([^.]+)\/htdocs\//i', realpath($_SERVER["SCRIPT_FILENAME"]), $regs))	$realpath = isset($regs[1])?$regs[1]:'';
+		
+		$entityCookieName = 'DOLENTITYID_'.md5($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].$realpath);
 		if (! empty($_COOKIE[$entityCookieName]) && ! empty($conf->file->cookie_cryptkey)) 						// Just for view specific login page
 		{
 			include_once(DOL_DOCUMENT_ROOT."/core/class/cookie.class.php");