将数组存储在Cookie中 [英] Store array in cookie
本文介绍了将数组存储在Cookie中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过php serialize函数将数组转换为cookie
I am converting the array into cookie by php serialize function
$PromoteProductArray = array("PromoteuserId"=>$PromoteuserId,
"PromoteProductId"=>$PromoteProductId,
"PromoteBrandId"=>$PromoteBrandId);
$Promotedcart[] = $PromoteProductArray;
setcookie("Promotedcart", serialize($Promotedcart), time()+604800,'/');
当创建cookie时,我使用unserialize php函数。
And when the cookie is created then i am using the unserialize php function.
print_r(unserialize($_COOKIE['Promotedcart']));
不起作用。
我 print_R($ _ COOKIE)
然后它显示我的值。
When I print_R($_COOKIE)
then it show me the value.
推荐答案
刚刚遇到一个情况,我也需要使用这个解决方案。我在这里找到了我的答案:在php 中更新Cookie值
Just ran into a situation where I also needed to use this solution. I found my answer here: update cookie value in php
这篇关于将数组存储在Cookie中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文