ASPにおけるCookiesのExpires属性の設定(JSバージョン)

1467 ワード

直接コードを通して、コードにコメントがあります.
<%@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