diff --git a/htdocs/core/class/cookie.class.php b/htdocs/core/class/cookie.class.php
index a45aaeb24235a434d267638fa67fd217bc06bfdf..39d27d9a332b14fd3add9f325a7f95b4ca3c96bd 100644
--- a/htdocs/core/class/cookie.class.php
+++ b/htdocs/core/class/cookie.class.php
@@ -91,7 +91,9 @@ class DolCookie
 			$num = (count($this->cookiearray) - 2);
 			for ($f = 0; $f <= $num; $f++)
 			{
-				$this->myValue .= strval(chr($this->cookiearray[$f]/$this->myKey));
+				if (!empty($this->myKey)) {
+					$this->myValue .= strval(chr($this->cookiearray[$f]/$this->myKey));
+				}
 			}
 
 			return(base64_decode($this->myValue));