想知道饼干和他们的陷阱。 [英] Wondering about cookie and their pitfalls.

查看:56
本文介绍了想知道饼干和他们的陷阱。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我使用setcookies存储一个单值。

但我正在读 http://za2.php.net/manual/en/function.setcookie.php 和我

注意到cookie可能不被接受但它可能会返回true。


所以这让我想知道如果我没有使用cookie会是什么

的方式确保它已被正确接受。

如果我必须制定
$ b $的备份计划,那么有什么意义? b不接受它们的用户?你为这些用户做了什么?


我是否正确地假设cookie仅用作奖励,例如

记住用户名和一些小设置。


现在我的变量,即使用户刷新页面,我怎么能记住这个值?

我有全球价值观......


if(!isset($ foo)){

$ foo =" value is set" ;;

echo"设置foo" ;;

}否则{

echo" foo is"。$ foo;

}


如果我加载页面$ foo已设置但是我刷新页面值为

丢失,为什么?

为什么php不记得全局值$ foo?


我试过

$ HTTP_GET_VARS [''foo''] = $ foo;

$ HTTP_POST_VARS [''foo''] = $ foo;


但刷新页面时不会保存值,(同一页

刷新)。


Sims

Hi,

I am using setcookies to store one single value.
But i was reading http://za2.php.net/manual/en/function.setcookie.php and i
noticed that a cookie might not be accepted yet it might return true.

So that makes me wonder what the use of the cookies are if i have no way of
making sure that it has been properly accepted.
What is the point of having cookies if i have to make a backup plan for
users that do not accept them? What do you do for those users?

Am i right in assuming that cookies are only used as a bonus, for example to
remember a user name and some minor settings.

Now for my variable, how can i remember the value even if the user refreshes
the page?

I have global values like...

if( !isset($foo) ){
$foo = "value is set";
echo "Setting foo";
}else{
echo "foo is".$foo;
}

if i load the page $foo is set but then is i refresh the page the value is
lost, why?
Why does php not remember the global value $foo?

I tried
$HTTP_GET_VARS[''foo''] = $foo;
$HTTP_POST_VARS[''foo'']= $foo;

But that does not save the value when the page is refreshed, (the same page
is refreshed).

Sims

推荐答案

foo)){
foo) ){


foo =" value is set" ;;

echoSetting foo;

} else {

echo" foo is"。
foo = "value is set";
echo "Setting foo";
}else{
echo "foo is".


foo;

}


如果我加载页面
foo;
}

if i load the page


这篇关于想知道饼干和他们的陷阱。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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