I am using this code to set a cookie and then see if they exist
setcookie("token", "value", time()+60*60*24*100, "/");
setcookie("secret", "value", time()+60*60*24*100, "/");
setcookie("key", "value", time()+60*60*24*100, "/");
if (!isset($_COOKIE['token']) || !isset($_COOKIE['secret']) || !isset($_COOKIE['key'])) {
// do something because one of the cookies were not set
}
Even though all three of the cookies were set in my browser, it still runs the if()
statement. Via the process of elimination I have discovered the middle cookie !isset($_COOKIE['secret'])
seems to cause the if()
statement to run even though the cookie secret
was set in my browser. The script says it has not been set when I look at my browser and it has been set. Can you think of any reason why php is saying it wasn't set?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…