Option Explicit ' 日付の設定 Function MakeLegalCookieDate(vDate) Dim sDays Dim sDay Dim sMonths Dim sMonth On Error Resume Next MakeLegalCookieDate = "" If Not IsDate(vDate) Then Alert "Not a valid date" Exit Function End If sDays = Array("Sunday", "Monday", "Tuesday", _ "Wednesday", "Thursday", "Friday", "Saturday") sMonths = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", _ "Jul", "Aug", "Sept", "Oct", "Nov", "Dec") sDay = sDays(Weekday(vDate, vbSunday)-1) sMonth = sMonths(DatePart("m", vDate)-1) If Err.Number > 0 Then Alert Err.Number & " " & Err.Description Exit Function End If MakeLegalCookieDate = sDay & ", " _ & DoubleDigit(DatePart("d",vDate)) & "-" _ & sMonth & "-" _ & DatePart("yyyy",vDate) & " " _ & DoubleDigit(DatePart("h",vDate)) & ":" _ & DoubleDigit(DatePart("n",vDate)) & ":" _ & DoubleDigit(DatePart("s",vDate)) & " " _ & "GMT" End Function ' 数字は2桁に整う Function DoubleDigit(sMaybeSingle) If Len(sMaybeSingle) = 1 then DoubleDigit = "0" & sMaybeSingle Else DoubleDigit = sMaybeSingle End If End Function 'クッキーの値をゲットする Function GetCookieValue(CookieName) Dim sCookie Dim vaCookies Dim sCookieVar Dim i sCookie = Document.Cookie vaCookies = Split(sCookie, ";") GetCookieValue = "" For i = 0 to UBound(vaCookies) dim tmpFind tmpFind = inStr(1, vaCookies(i), "=") If tmpFind > 0 Then sCookieVar = trim(Left(vaCookies(i), tmpFind - 1)) if sCookieVar = CookieName then GetCookieValue = mid(vaCookies(i), tmpFind + 1) Exit For end If End If Next End Function 'クッキーを削除する Sub DeleteCookie(CookieName) Dim vExpire vExpire = MakeLegalCookieDate(DateAdd("d", -1, Now())) document.cookie = CookieName + "=" + "NULL;expires=" + vExpire End Sub