有关COOKIES的问题 [英] Problem reagarding COOKIES

查看:62
本文介绍了有关COOKIES的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生/女士



我使用asp.net,VB作为默认语言,并使用sql server作为后端。

我想在单个Cookie中存储多个值。

请帮我解决此问题。



先生我有一个表格



id(textbox1)



(按钮1)





先生我希望我把id设为1,然后点击按钮,然后点击文本框中的值添加到cookie中。



此时在饼干中我们有价值

1





又一次我将id作为2放在文本框1中,然后单击按钮,然后2也添加cookie。



现在当我看到cookie的值时,它必须显示值为

1

2



请帮我完成这个任务

Dear Sir/Ma''am

I am using asp.net with VB as default language and using sql server as backend .
I want to store multiple values in a Single Cookie .
Please Help me regarding this.

Sir i have a form

id (textbox1)

(Button 1)


Sir I want that i put the id as 1 in textbox1 and click on button then value of text box add in the cookie.

At this time in the cookie we have value
1


And when again i put the id as 2 in text box1 and click on the button then 2 also add in the cookie.

Now When i see the value of cookie then it must shows the values as
1
2

Please Help me to do this task

推荐答案

您好,



使用cookies:



Hi,

Use of cookies:

////////////SET THE COOKIE//////////////

Response.Cookies["test"].Value = UserName.Text ;

Response.Cookies["test"].Expires = DateTime.Now.AddYears(30);

where test is the cookie name

and the username.text is the textbox that will be used to define the cookies information

in order to delete a cookie use this
Response.Cookies["test"].Expires = DateTime.Now.AddYears(-30);

in order to check whether the cookie is found or not and retrieve the cookies information use this
/////////check to see if cookie presented//////////

if (Request.Cookies["test"] == null)

TextBox2.Text = "No cookie found";

else

TextBox2 .Text = Request.Cookies["test"].Value;

/////////END check to see if cookie presented//////////





对于多个值,请参考以下链接:



在cookie中存储多个值

具有多个值的ASP.NET cookie - 如何?



希望这会让你感到高兴。

谢谢



For multiple values refer the following links:

Storing multiple values in cookies
ASP.NET cookies with multiple values - how to?

Hope this will hep you.
Thanks


ASP.NET中的Cookie基础知识 [ ^ ]应该可以帮助您开始使用基础知识。

如何:写一个Cookie [ ^ ]是另一个很好的基本链接。



初学者的ASP.NET Cookie指南 [ ^ ]可能是也很有用。
Basics of Cookies in ASP.NET[^] should help you get started with the basics.
How to: Write a Cookie[^] is another good basic link.

Beginner''s Guide to ASP.NET Cookies[^] could be useful too.


这篇关于有关COOKIES的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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