You are here: Re: Cookie array does not work ? « PHP Programming Language « IT news, forums, messages
Re: Cookie array does not work ?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация