<?php /* * @Content : session && cookie * @author : Mr.xml * @time : 2015-3-17 09:53:49 */ session_start(); //开启session header("Content-type:text/html;charset=utf-8"); //设置字符编码 $_SESSION[‘arr‘] = array( ‘name‘ =>‘xx‘, ‘age‘=>20, ‘sex‘=>‘is_nan‘, ); session_destroy(); //销毁session if(isset($_SESSION)){ print_r($_SESSION); }else{ echo "session以销毁!"; } /////////////////////////////////////////////////////////////////// // php设置cookie ,php中cookie如何以数组的方式进行存储 $arr = array( ‘name‘=>‘xxxx22‘, ‘sex‘=>‘boys‘, ‘age‘=>21, ); //数组转换字符串存储 $cookie = serialize($arr); //设置cookie setcookie(‘cookies‘,$cookie,time()+60*60); print_r($cookies); setcookie(‘cookies‘,‘‘,time()-3600) //销毁cookie if(isset($cookies)){ print_r($cookies); }else{ echo "cookie已销毁!"; }
时间: 2024-10-13 14:41:48