note 35647 modified in function.setcookie by danbrown

From: Date: Sun, 17 May 2009 18:02:50 +0000
Subject: note 35647 modified in function.setcookie by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155055@lists.php.net to get a copy of this message
There are several characters that dont work correctly if part of the cookie name, I in particular ran into problems using = as part of the cookie name ie/ <?php setcookie('dE4fR=', $foo); ?> this was as a result of base64_encode() ing a variable to use as the name. The cookie was being set fine but the = is stored as a little square character in the cookie which prevent proper retreival. The solution for me was to use md5() instead of base64_encode() but any other method which avoids the = sign should also solve the problem --was-- There are several characters that dont work correctly if part of the cookie name, I in particular ran into problems using = as part of the cookie name ie/ setcookie('dE4fR=', $foo); this was as a result of base64_encode() ing a variable to use as the name. The cookie was being set fine but the = is stored as a little square character in the cookie which prevent proper retreival. The solution for me was to use md5() instead of base64_encode() but any other method which avoids the = sign should also solve the problem http://php.net/manual/en/function.setcookie.php

« previous php.notes (#155055) next »