我以前,但从来没有使用的Cookie的会话。我想使用cookie有两个原因:
1)这是一些新的学习
2)我想有一个小时左右的cookie过期(我知道它的代码示例过期40秒)Incrmenting用PHP饼干(初级问题)
我想写一个基本的if语句
if($counter=="1") { //do this second
}
elseif ($counter >="2") { //do this every time after the first and second
}
else {// this is the first action as counter is zero
}
这里是我使用的设置Cookie代码:
// if cookie doesnt exsist, set the default
if(!isset($_COOKIE["counter_cookie"])) {
$counter = setcookie("counter_cookie", 0 ,time()+40);
}
// increment it
$counter++;
// save it
setcookie("counter_cookie", $counter,time()+40);
$counter = $_COOKIE["counter_cookie"];
的问题是,反会SE t从0到1,但不会从1到2,等等。任何帮助将是伟大的我知道这是一个非常简单的愚蠢问题:|
谢谢!
谁从饼干罐里面偷走了饼干? – Rob 2010-04-24 03:31:53
你偷饼干的饼干罐! – BandonRandon 2010-04-24 03:35:00