|
Posted by BKDotCom on 10/12/05 21:49
Harry Haller wrote:
> But this does not work:
>
> // (2) Set new cookies
> setcookie ("font[type]", $type_sel, time()+3600);
> setcookie ("font[size]", $size_sel, time()+3600);
> // (2) Get most recent cookie
> $font[type] = $_COOKIE["font[type]"];
> $font[size] = $_COOKIE["font[size]"];
> if (isset($font[type]) && isset($font[size]))
> echo "Found Cookies<br>\n";
>
a) the newly set values won't be avail in the $_COOKIE array until the
next time you load the page.
b) by using the []s php assumes you want to use an array-like
structure...
$_COOKIE now looks like array(
'font' => array(
'type' => x,
'size' => y,
),
any other values....
)
print_r($_COOKIE); // print_r is your friend
so you'd access 'size' via $_COOKIE['font']['size']
note: you're actually setting/saving 2 discret cookies this way..
php just creates the single font array.
I prefer to manually serialize/unserialize.
Navigation:
[Reply to this message]
|