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

首頁 > 編程 > ASP > 正文

javascript asp教程第九課--cookies

2024-05-04 11:01:54
字體:
來源:轉載
供稿:網友

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>            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 罗定市| 扎兰屯市| 金溪县| 天气| 桐梓县| 文成县| 仁化县| 锡林浩特市| 镇雄县| 永川市| 诏安县| 雅江县| 高邮市| 庆元县| 托里县| 资源县| 静海县| 拉孜县| 钦州市| 武威市| 莆田市| 普兰县| 蕉岭县| 普兰店市| 依安县| 遂宁市| 晴隆县| 黎川县| 余庆县| 贵州省| 汉中市| 衢州市| 南召县| 乳山市| 延吉市| 蒙自县| 陇南市| 九江市| 驻马店市| 林西县| 类乌齐县|