饼干和PHP - 基础知识 [英] cookies and php - basics

查看:59
本文介绍了饼干和PHP - 基础知识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我能提出的最简单的例子,但出于某种原因

(不是我浏览器的设置)它不起作用......

[页面顶部]

<?php

setcookie($ cookie_name," cookie_content",time()+ 3600);

?>

<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN"

" http:// www.w3.org/TR/html4/loose.dtd">

< html>

< head>

< title> cookie test< / title>

< meta http-equiv =" Content-Type"含量=" text / html的; charset = iso-8859-1">

< / head>

< body>

< p>

<?php

if(isset($ cookie_name))

{

print" Welcome! < br>" ;;

}

else

{

print" Go away。 ;

}

?>

< / p>

< / body>

< / html>


我错过了什么吗? thx

This is about the simplest example I could come up with, but for some reason
(not my browser''s settings) it''s not working...
[top of page]
<?php
setcookie($cookie_name, "cookie_content", time()+3600);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>cookie test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
<?php
if (isset($cookie_name))
{
print "Welcome! <br>";
}
else
{
print "Go away.";
}
?>
</p>
</body>
</html>

Am I missing something? thx

推荐答案

cookie_name," cookie_content",time()+ 3600);

?>

<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN"

" http://www.w3.org/TR/html4 /loose.dtd">

< html>

< head>

< title> cookie test< / title>

< meta http-equiv =" Content-Type"含量=" text / html的; charset = iso-8859-1">

< / head>

< body>

< p>

<?php

if(isset(
cookie_name, "cookie_content", time()+3600);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>cookie test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
<?php
if (isset(


cookie_name))

{

打印欢迎! < br>" ;;

}

else

{

print" Go away。 ;

}

?>

< / p>

< / body>

< / html>


我错过了什么吗? thx
cookie_name))
{
print "Welcome! <br>";
}
else
{
print "Go away.";
}
?>
</p>
</body>
</html>

Am I missing something? thx


啊哈......搞定了工作


<?php
Ah Ha... got it working

<?php


这篇关于饼干和PHP - 基础知识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆