[nycphp-talk] Problem With Making Cookies
Chris Shiflett
shiflett at php.net
Wed Apr 12 07:35:49 EDT 2006
IAlsoAgree at stny.rr.com wrote:
> $cookiedata = $infoarray[0].'#'.$infoarray[1].'#'.$infoarray[2];
You should definitely check out implode().
> However, when I actually check the data inside the cookie, it's
> saved not with pound signs in between the data, but instead with
> %23.
That's something setcookie() does. You can use header() if you want to
have precise control over your Set-Cookie header. Try this example:
<?php
$info = array();
$info[] = 'one';
$info[] = 'two';
$info[] = 'three';
$cookie = implode('#', $info);
header("Set-Cookie: foo=$cookie");
setcookie('bar', $cookie);
?>
The headers I see are:
Set-Cookie: foo=one#two#three
Set-Cookie: bar=one%23two%23three
Hope that helps.
Chris
More information about the talk
mailing list