note 77276 added to function.setcookie

From: Date: Wed, 22 Aug 2007 14:55:02 +0000
Subject: note 77276 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-129706@lists.php.net to get a copy of this message
If you're looking to set multiple values in your cookie (rather than setting multiple cookies) you might find these useful. <?php function build_cookie($var_array) { if (is_array($var_array)) { foreach ($var_array as $index => $data) { $out.= ($data!="") ? $index."=".$data."|" : ""; } } return rtrim($out,"|"); } function break_cookie ($cookie_string) { $array=explode("|",$cookie_string); foreach ($array as $i=>$stuff) { $stuff=explode("=",$stuff); $array[$stuff[0]]=$stuff[1]; unset($array[$i]); } return $array; } ?> Hopefully someone finds these useful. ---- Server IP: 66.207.199.35 Probable Submitter: 65.95.156.141 ---- Manual Page -- http://www.php.net/manual/en/function.setcookie.php Edit -- https://master.php.net/note/edit/77276 Del: integrated -- https://master.php.net/note/delete/77276/integrated Del: useless -- https://master.php.net/note/delete/77276/useless Del: bad code -- https://master.php.net/note/delete/77276/bad+code Del: spam -- https://master.php.net/note/delete/77276/spam Del: non-english -- https://master.php.net/note/delete/77276/non-english Del: in docs -- https://master.php.net/note/delete/77276/in+docs Del: other reasons-- https://master.php.net/note/delete/77276 Reject -- https://master.php.net/note/reject/77276 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129706) next »