php设置的cookie和js设置的cookie可以同名存在0
kb123242013.07.26浏览139次分享举报
发现js设置完cookie后再用php重设置cookie竟然同名同时存在,而且用php取出cookie的值还是js设置的那个值,不理解??<?php
if($_GET['act']=='m_time' )
{
$m_time = $_POST['m_time13'];
unset($_COOKIE['m_time']);
setcookie('m_time',$m_time,time()+60*60*24*600,'/');
header('location:'.$_SERVER['HTTP_REFERER']);
}
?>
无标题文档function checktime(){
m_time = document.timeform.m_time13.value;
var pattern = /^(\d{4})-(\d{1,2})-(\d{1,2})$/g;
if(!pattern.test(m_time)){
alert('格式不正确,格式如(2010-01-01)');
return ;
}
document.timeform.submit();
}
function CookieEnable()
{
var result=false;
if(navigator.cookiesEnabled)
return true;
document.cookie = "testcookie=yes;";
var cookieSet = document.cookie;
if (cookieSet.indexOf("testcookie=yes") > -1)
result=true;
document.cookie = "testcookie=";
return result;
}
if(!CookieEnable())
{
alert("对不起,您的浏览器的Cookie功能被禁用,请开启");
} alert(document.cookie);
if(document.cookie.indexOf("m_time")=='-1'){
document.cookie="m_time=2010-08-14";
//SetCookie('m_time','2010-08-14');
document.URL='untitled-1.php';
}
时间: