?删除我的网站的所有Cookie /使用Cookie的通配符 [英] ? Deleting All of My Site's Cookies / Using Wildcards With Cookie

查看:86
本文介绍了?删除我的网站的所有Cookie /使用Cookie的通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在使用JavaScript和Cookie在网页中进行一些自定义。

cookie中可能有几个值

运行时未知的名称。我需要一种删除它们的方法。


例如,如果我的网站是 www.test.com 和饼干包含:


label1

fob

... 。

*


name1

foo

....

*

name2

bar

....

*

name3

baz

....

*


等等,那么我会编写一个简单地删除这些值的函数

,其循环计算name1,name2,name3等等。不幸的是

我的cookie将使用不同的标签,而不是name1,name2,name3 ......,实际上我

无法确切地知道它们之前会被称为什么

他们会有一些我可以预测的东西。


我可以在值名中使用通配符,例如。在上面的例子中,我可以

删除" name *"或* 1?或者,有没有办法只删除cookie中的所有

值?

谢谢。


-

news<。> alec< @> synetech<。> cjb<。> net

解决方案

哦,我知道我必须将值设置为expal才能将其删除。我想要的是
寻找未知价值(名字)的方法。

-

news<。> alec< @> synetech<。> cjb<。> net


Alec S.写道:

哦,我知道我必须将值设置为expal才能删除它。我正在寻找的是一种使未知值(名称)失效的方法。




将cookie的截止日期设置为在过去的日期,cookie将会过期,并且它将会消失。然后,你用你想要的数据

重置cookie。


-

Randy


Randy Webb于2005年4月17日在comp.lang.javascript中写道

Alec S.写道:

哦,我知道我必须将值设置为过期才能将其删除。我正在寻找的是一种使未知值(名称)失效的方法。



将cookie的过期日期设置为过去的日期, cookie将会过期,它将会消失。然后,使用您想要的数据重置cookie。




您必须相信过去没有设置的客户端时间。

-

Evertjan。

荷兰。

(用我的电子邮件地址替换所有带点的十字架)


Hi,

I''m using JavaScript and Cookies for some customization in a web page.
There may be several values in the cookie with names that are not known at
runtime. I need a way of deleting them.

For example, if my site is www.test.com and the cookie contains:

label1
fob
....
*

name1
foo
....
*
name2
bar
....
*
name3
baz
....
*

and so on, then I would write a function that simply deletes these values
with a loop that counts off name1, name2, name3, et cetera. Unfortunately
my cookie will use different labels, not name1, name2, name3..., in fact I
have no way of knowing exactly what they will be called beforehand although
they will have some things I can predict.

Can I use wildcards in the value-name, eg. in the above example, could I
delete "name*" or "*1"? Alternatively, is there a way to just delete ALL
values in the cookie?
Thanks.

--
news <.> alec <@> synetech <.> cjb <.> net

解决方案

Oh, and I know I have to set the value to expire to delete it. What I''m
looking for is a way to expire unknown values (names).
--
news <.> alec <@> synetech <.> cjb <.> net


Alec S. wrote:

Oh, and I know I have to set the value to expire to delete it. What I''m
looking for is a way to expire unknown values (names).



Set the expiration date on the cookie to a past date, the cookie will be
expired and it will be gone. Then, you reset the cookie with the data
you want.

--
Randy


Randy Webb wrote on 17 apr 2005 in comp.lang.javascript:

Alec S. wrote:

Oh, and I know I have to set the value to expire to delete it. What I''m
looking for is a way to expire unknown values (names).



Set the expiration date on the cookie to a past date, the cookie will be
expired and it will be gone. Then, you reset the cookie with the data
you want.



You will have to trust the client time not being set in the past.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


这篇关于?删除我的网站的所有Cookie /使用Cookie的通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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