cookie 记录用户方位次数 //// 判断客户端浏览器禁用cookie否

//用户访问次数;;
if(empty($_COOKIE['count'])){
	echo "您好,欢迎您第一次访问本网";
	setcookie("count","1",time()+(86400 * 365),"/");
}else{
	$count = intval($_COOKIE['count']); //intval — 获取变量的整数值
	$count++;
	echo "您是第{$count}次访问本网";
	setcookie("count",$count,time()+(86400 * 365),"/");
}



  //检测客户浏览器是否支持cookie写入
  if(empty($_GET['flag'])){
   //... 第一次写入cookie
   setcookie("flag","yes",time()+60,"/");
   //刷新. . .---先取到现在的地址
   //现在地址..????
   //http://172.164.20.46/0828/8.php?flag=yes
   $url = "http://".$_SERVER['SERVER_NAME'];
   $url .= $_SERVER['PHP_SELF']."?flag=yes";
   header("Location: ".$url);
  }else{
   //读取flag 开启cookie
   if(!empty($_COOKIE['flag'])){
       echo "cookie开启"; 
   }else{
       echo "cookie禁用"; 
   }
  }

你可能感兴趣的:(cookie)