Forum Moderators: coopster
I'm trying to set a cookie using PHP where the value has a colon (:).
setcookie("name", "1236:abcde", strtotime($expire), "/");
This results in a cookie being set with the value of
1236%3Aabcde
From what I can find out, a colon is an allowable character in a cookie value and is used as a delimiter quite often.
Any ideas how to get the colon in the cookie value?
Thanks
A quote from the manual -
Note that the value portion of the cookie will automatically be urlencoded when you send the cookie, and when it is received, it is automatically decoded and assigned to a variable by the same name as the cookie name. If you don't want this, you can use setrawcookie() instead if you are using PHP 5.
So im guessing your : is getting encoded by the setcookie function. Try setrawcookie if you have php 5. If not then you can always use the header function to set your cookie.
Also is the %3A coming up in the browser or in the $_COOKIE array? As you should be getting : in the cookie array just the encoded value in the browser.
[edited by: PHP_Chimp at 10:13 pm (utc) on Oct. 17, 2007]
I am guessing from reading the bit I quoted from the manual that if you look in the $_COOKIE or $_REQUEST array that the value will be back with a :.
So you will need to print_r($_COOKIE) to test my theory.
If that doesnt work then use the header function to set the cookie, as this doesnt urlencode anything.