Re: Grab an array from a cookie without throwing errors?
| From: | John Nichel | Date: | Fri, 08 Oct 2004 16:04:05 +0000 |
| Subject: | Re: Grab an array from a cookie without throwing errors? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-198984@lists.php.net to get a copy of this message | ||
Brian Dunning wrote:
I've got a cookie that's either non-existent or a serialized array. I'm trying all sorts of different code combinations to retrieve it into an array variable, but everything I try throws up some combination of notices and/or warnings. Here is my latest & greatest: $cookie = $_COOKIE['bookmarks']; if(unserialize($cookie) == true) {Use isset if ( isset ( $_COOKIE['bookmarks'] ) && unserialize ( $_COOKIE['bookmarks'] ) ) { $bookmarks = unserialize ( $_COOKIE['bookmarks'] ); } else { $bookmarks = array(); } -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com$bookmarks = unserialize($cookie);} else {$bookmarks = array();}