标签:
直接上代码,代码中有注释
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> <% var numVisits; var myDate = new Date(); myDate.setDate(myDate.getDate() + 365); //设置为1年之后 var mon = new Array("January","February","March","April","May","June","July","August","September","October","November","December") var exps = mon[myDate.getMonth()] + " " + myDate.getDate() + "," + myDate.getFullYear(); Response.Cookies("numvisits").Expires = exps; numVisits = Request.Cookies("numvisits"); if(!numVisits) { //第一次登陆 Response.Cookies("numvisits") = 1; Response.Write("<h1>欢迎,这是您第一次访问该页面</h1>"); } else { numVisits++; Response.Write("<h1>这是您第 " + numVisits + " 次访问</h1>"); Response.Cookies("numvisits") = numVisits; } %>
JavaScript 脚本编写 Cookies 的 Expires 属性时尽量设置为日期字符格式:
January 9,2017
ASP 中 Cookies 的 Expires 属性的设置(JS版本)
标签:
原文地址:http://www.cnblogs.com/pchmonster/p/5119911.html