RE: [PHP] Re: Cookie array
| From: | Maxim Maletsky | Date: | Sun, 11 Aug 2002 21:56:48 +0000 |
| Subject: | RE: [PHP] Re: Cookie array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112051@lists.php.net to get a copy of this message | ||
It is way smarter storing serialized array in one cookie. And, if you
get length problems then only store SESSID in cookie and the rest in
session or database.
Sincerely,
Maxim Maletsky
PHP Beginner
www.phpbeginner.com
> -----Original Message-----
> From: B.C. Lance [mailto:lornie@magix.com.sg]
> Sent: Sunday, August 11, 2002 6:11 PM
> To: php-general@lists.php.net
> Subject: [PHP] Re: Cookie array
>
> to store:
>
> setcookie ("TestCookie[0]", "zero", time() + 3600);
> setcookie ("TestCookie[1]", "one", time() + 3600);
> setcookie ("TestCookie[2]", "two", time() + 3600);
>
> or
>
> setcookie ("TestCookie[one]", "1", time() + 3600);
> setcookie ("TestCookie[two]", "2", time() + 3600);
> setcookie ("TestCookie[three]", "3", time() + 3600);
>
>
> to retrieve:
>
> foreach($_COOKIE["TestCookie"] as $key => $value) {
> echo "{$value}<br>";
> }
>
> or
>
> echo $_COOKIE["TestCookie"]["one"];
> echo $_COOKIE["TestCookie"][1];
>
>
> Jan - Cwizo wrote:
> > Hi !
> >
> > How can I stoor array in to a cookie ?
> >
> > Do I just define an array and stoore it in a cookie ?
> > How do I access the data in the array then ?
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php