diff --git a/ecrire/inc/cookie.php b/ecrire/inc/cookie.php
index 020b24cabe96fe5585eba5f9d9f9c0155caafd36..e39b9952e9f1ec1c7e1088951745313eb8da8f2e 100644
--- a/ecrire/inc/cookie.php
+++ b/ecrire/inc/cookie.php
@@ -35,15 +35,16 @@ function spip_setcookie ($name='', $value='', $expire=0, $path='AUTO', $domain='
 
 function recuperer_cookies_spip($cookie_prefix) {
 	global $_COOKIE;
+	$prefix_long = strlen($cookie_prefix);
 
 	foreach ($_COOKIE as $name => $value) {
-		if (ereg('^spip_', $name)) {
+		if (substr($name,0,5)=='spip_' && substr($name,0,$prefix_long)!=$cookie_prefix) {
 			unset($_COOKIE[$name]);
 			unset($GLOBALS[$name]);
 		}
 	}
 	foreach ($_COOKIE as $name => $value) {
-		if (ereg('^'.$cookie_prefix.'_', $name)) {
+		if (substr($name,0,$prefix_long)==$cookie_prefix) {
 			$spipname = ereg_replace ('^'.$cookie_prefix.'_', 'spip_', $name);
 			$_COOKIE[$spipname] = $value;
 			$GLOBALS[$spipname] = $value;