简体   繁体   English

不会设置Cookie吗?

[英]Cookies won't set?

So, I'm making a simple website blocked script, and in the end it will just say website blocked, and will foreword someone to a page like igoogle, with weather, news, and such, but I can't create a cookie at all, in any script. 因此,我正在制作一个简单的网站被阻止脚本,最后它只会说网站被阻止,并且将某人与igoogle等网页一起添加天气,新闻等信息,但我无法在其中创建Cookie全部,使用任何脚本。 I put the create cookie script in the same page as the read cookie script. 我将创建cookie脚本与读取cookie脚本放在同一页面中。 What am I doing wrong? 我究竟做错了什么?

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>***WEBSITE BLOCKED***</title>
</head>
<body>
<?php
$expire=3600;
echo $expire;
setcookie("user2112", "Justin Marmorato", $expire);
if (isset($_COOKIE["user2112"]))
echo "Welcome " . $_COOKIE["user2112"] . "!<br>";
else
echo "Welcome guest!<br>";
?>
</body>
</html>

Heres the output every time 3600Welcome guest! 每次3600输出以下信息欢迎客人!

I got it... You should set 我知道了...你应该设定

$expire = time()+3600;

not

$expire = 3600;

OK... I tested it and it works... 好...我测试了一下,它就可以了...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM