php在一个cookie中存储多个值得代码演示
<?php $info = array("xyz", "yellow", 22); setcookie("usr", serialize($info)); ?> <html><head><title>Multiple Cookie Values</title></head> <h2>$_COOKIE[]</h2> <b> <?php if(! empty($_COOKIE['usr'])){ $cookie_data= $_COOKIE['usr']; $cookie_data=stripslashes($cookie_data); $cookie_data=unserialize("$cookie_data"); echo "What's in the cookie array< br />"; print_r($_COOKIE); echo "<pre class="prettyprint linenums" >Unserialized data< br />"; print_r( $cookie_data); } ?> </b> </font> </body>