php中有关setcookie的使用
1.设置cookie变量赋值:
setcookie ("cookiename", "name",time()+365*24*3600, "/", ".test.com");
//给cookiename赋了name,有效限是一年。本地的cookie下会有一个user@test.com文本.
2.设置cookie数组:
setcookie ("cookiename[$i]", "name",time()+365*24*3600, "/", ".test.com");
3.读取cookie的内容:
a.非数组:$tmp_test=$_cookie['cookiename'];//取setcookie ("cookiename", "name",time()+365*24*3600, "/", ".test.com");这条的值
b.数组:$tmp_test=$_cookie['cookiename'][$i];//取setcookie ("cookiename[$i]", "name",time()+365*24*3600, "/", ".test.com");这条的值
4.清空cookie:
a.非数组:setcookie ("cookiename", "",time()-2*365*24*3600, "/", ".test.com");
b.数组:setcookie ("cookiename[$i]", "",time()-2*365*24*3600, "/", ".test.com");