最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
最新的关于Cookies的操作
时间:2022-06-30 09:59:47 编辑:袖梨 来源:一聚教程网
So anyways, on to the code. The first thing we need to think of is exactly what data will need to be
stored in the cookie. In this case we will use info submitted by the user via this form:
Now let's get to the fun part, setting the cookie info. You can use the following code to set the cookie
value on the clients machine:
<%
Response.buffer = True
' first we put the data from the form into a variable
name = Request.Form("name")
'then we can set the cookie value using this:
Response.Cookies("name") = name
%>
Ok, so now the cookie is set and we need to retrieve the info. You can use this to retrive the cookie
data:
<%
' first we retrive the data and set it to a variable
name = Request.Cookies("name")
' then we post it to the website
Response.Write (name)
%>
And it's that easy. But wait, there is more. There are a few properties that you can set using cookies.
The first property is the Domain property. This is the domain that the cookie originated from. The cookie
can only be read by the domain it originated from. It is set by default to the domain in which it was
created, but you can alter it for your needs. You can set it using this:
Response.Cookies("name").Domain = "www.cookiemonster.com"
The next important property is the Expires property. This specifies the date the cookie should expire. If
it is set to a past date then it will expire when the browser is closed.
When setting the date it can be set a couple of ways. You can use the current date and add or subtract
stored in the cookie. In this case we will use info submitted by the user via this form:
Now let's get to the fun part, setting the cookie info. You can use the following code to set the cookie
value on the clients machine:
<%
Response.buffer = True
' first we put the data from the form into a variable
name = Request.Form("name")
'then we can set the cookie value using this:
Response.Cookies("name") = name
%>
Ok, so now the cookie is set and we need to retrieve the info. You can use this to retrive the cookie
data:
<%
' first we retrive the data and set it to a variable
name = Request.Cookies("name")
' then we post it to the website
Response.Write (name)
%>
And it's that easy. But wait, there is more. There are a few properties that you can set using cookies.
The first property is the Domain property. This is the domain that the cookie originated from. The cookie
can only be read by the domain it originated from. It is set by default to the domain in which it was
created, but you can alter it for your needs. You can set it using this:
Response.Cookies("name").Domain = "www.cookiemonster.com"
The next important property is the Expires property. This specifies the date the cookie should expire. If
it is set to a past date then it will expire when the browser is closed.
When setting the date it can be set a couple of ways. You can use the current date and add or subtract
相关文章
- 沙丘觉醒怎么饮血快速解渴 饮血解渴方法介绍 07-15
- 最终幻想14水晶世界居格斯怎么打 强腕的居格斯打法分享 07-15
- 沙丘觉醒怎么更改哈克南厄崔迪家族阵营 阵营转换方法 07-15
- 欧易app注册下载 欧易app交易所v6.7.0 07-15
- 剑星乌龙谷物茶饮料罐在哪 乌龙谷物茶饮料罐收集位置一览 07-15
- 幻兽帕鲁熔岩兽出没地点 帕鲁熔岩兽捕捉位置介绍 07-15