国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

javascript asp教程第九課--cookies

2024-05-04 10:58:18
字體:
來源:轉載
供稿:網友

Response Cookies in General:

We'll start with the Response Cookies collection. I don't think it could be any easier. You simply put the name of the cookie in the argument. The corresponding value is a string. The only time it gets complicated is when you use keys (which I demonstrate below).

<%@LANGUAGE="JavaScript"%><%var Tomorrow=new Date()Tomorrow.setDate(Tomorrow.getDate() + 1)myExpire = (Tomorrow.getMonth() + 1) + "/" + Tomorrow.getDate() myExpire += "/" + Tomorrow.getFullYear()Response.Cookies("firstCookie") = "I like cookies."Response.Cookies("firstCookie").Expires=myExpireResponse.Cookies("secondCookie") = "ASP Cookies Are Easy."Response.Cookies("secondCookie").Expires=myExpireResponse.Cookies("thirdCookie")("firstKey")="Here's the first Key."Response.Cookies("thirdCookie")("secondKey")="Here's the second Key."Response.Cookies("thirdCookie").Expires=myExpire%><HTML>We're just setting <%=Response.Cookies.Count%> cookies.<BR><A HREF="script09a.asp">Click Here</A> to retrieve these cookies.</HTML>

Click Here to run the script in a new window.

Setting a cookie with ASP is pretty simple. The format is Response.Cookies("name")="value". That "value" can be either a JavaScript string or an ASP native type such as Request.Form("userEmail").

Response Cookie Keys:

If on the first page of your ASP application Response.Cookies("myOnlyCookie") is set, and subsequently on page two of your application Response.Cookies("myOnlyCookie") is reassigned a second value, then only the second value will remain. The first value is lost in this circumstance.

The solution is to either use multiple cookies or to use multiple Keys in the SAME cookie.

Response.Cookies("thirdCookie")("firstKey")="Here's the first Key."Response.Cookies("thirdCookie")("secondKey")="Here's the second Key."

The Setting of one or more Keys is pretty simple. It follows this format: Response.Cookies("name")("key")="value". Again, the "value" can either be a JavaScript string or ASP native type. The advantage of using keys is that you can store multiple Key/Value pairs inside the very same cookie.

Request Cookies:

Generally you will find ASP cookie management to be far easier than Client Side JavaScript cookies. Down below is the script that retrieves the cookies.

<%@LANGUAGE="JavaScript"%><%if (Response.Cookies.Count <= 0)	{	Response.Redirect("script09.asp")	}var firstCookie = Request.Cookies("firstCookie"); var secondCookie = Request.Cookies("secondCookie");var thirdCookie2Keys = Request.Cookies("thirdCookie")("firstKey") thirdCookie2Keys += " " + Request.Cookies("thirdCookie")("secondKey");%><HTML>There are <%=Request.Cookies.Count%> Cookies.<BR>1) <%=firstCookie%><BR>2) <%=secondCookie%><BR>3) <%=thirdCookie2Keys%><BR><A HREF="script09b.asp">Click Here</A> to see how we would sort cookiesif we didn't know their names.</HTML>            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 蚌埠市| 神农架林区| 巨鹿县| 永嘉县| 阿鲁科尔沁旗| 南澳县| 武强县| 台中市| 富蕴县| 麟游县| 顺义区| 天祝| 米泉市| 滦南县| 巍山| 平武县| 沅江市| 舒兰市| 浙江省| 辉县市| 斗六市| 涞源县| 安化县| 三门峡市| 馆陶县| 秦皇岛市| 新巴尔虎右旗| 固始县| 陆川县| 信宜市| 固镇县| 东乡| 阜南县| 桃园县| 屯昌县| 兴仁县| 礼泉县| 丹寨县| 清远市| 建瓯市| 手机|