Re: [PHP] Grab an array from a cookie without throwing errors?

2004-10-09 Thread Chris Dowell
pedantry Of course, you're running unserialize() twice. What about if (empty($_COOKIE['bookmarks']) || !($bookmarks = unserialize($_COOKIE['bookmarks']))) { $bookmarks = array(); } Does the same with only one call to a potentially weighty function. /pedantry Cheers Chris John Nichel wrote:

Re: [PHP] Grab an array from a cookie without throwing errors?

2004-10-09 Thread Chris Dowell
pedantry Of course, you're running unserialize() twice. What about if (empty($_COOKIE['bookmarks']) || !($bookmarks = unserialize($_COOKIE['bookmarks']))) { $bookmarks = array(); } Does the same with only one call to a potentially weighty function. /pedantry Cheers Chris John Nichel wrote:

[PHP] Grab an array from a cookie without throwing errors?

2004-10-08 Thread Brian Dunning
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 =

Re: [PHP] Grab an array from a cookie without throwing errors?

2004-10-08 Thread Matt M.
$cookie = $_COOKIE['bookmarks']; if(unserialize($cookie) == true) { $bookmarks = unserialize($cookie); } else { $bookmarks = array(); } if (isset($_COOKIE['bookmarks'])) { $cookie = $_COOKIE['bookmarks']; if(unserialize($cookie) == true) { $bookmarks =

Re: [PHP] Grab an array from a cookie without throwing errors?

2004-10-08 Thread John Nichel
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 =