日期:2014-05-16  浏览次数:21023 次

ASP中设置cookie的HttpOnly属性
在网上看到cookie如何设置HttpOnly的属性,并贴出代码,却始终找不到ASP是如何设置的。有没有会的帮我贴一下代码,新人求救~~

------解决方案--------------------
http://stackoverflow.com/questions/2990686/setting-httponly-for-classic-asp-session-cookie

要想要重写过。。
------解决方案--------------------
<%
‘**************************************************
‘ASP 中输出httponly cookie IE6.0以上浏览器支持
‘WDFrog
‘2009-04-15
‘<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
‘**************************************************

‘———-SetHttpOnlyCookie—————————————-
‘功能:设置HttpOnly Cookie
‘参数:expDate 为保到期, 0表示不设置,设置为过去某一时间表示清除
‘参数:domain 为空(string.Empty)表示不设置
‘——————————————————————-
Function SetHttpOnlyCookie(cookieName,cookieValue,domain,path,expDate)
Dim cookie
cookie=cookieName & “=” & Server.URLEncode(cookieValue) & “; path=” & path
If expDate <> 0 Then
cookie=cookie & “; expires=” & DateToGMT(expDate)
End If

If domain <> “” Then
cookie=cookie & “; domain=” & domain
End If

cookie=cookie & “; HttpOnly”

Call Response.AddHeader (”Set-Cookie”, cookie)
End Function

‘————-getGMTTime————
‘参数: sDate 需要转换成GMT的时间
‘———————————
Function DateToGMT(sDate)
Dim dWeek,dMonth
Dim strZero,strZone
strZero=”00″
strZone=”+0800″
dWeek=Array(”Sun”,”Mon”,”Tue”,”Wes”,”Thu”,”Fri”,”Sat”)
dMonth=Array(”Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”Aug”,”Sep”,”Oct”,”Nov”,”Dec”)
DateToGMT = dWeek(WeekDay(sDate)-1)&”, “&Right(strZero&Day(sDate),2)&” “&dMonth(Month(sDate)-1)&” “&Year(sDate)&” “&Right(strZero&Hour(sDate),2)&”:”&Right(strZero&Minute(sDate),2)&”:”&Right(strZero&Second(sDate),2)&” “&strZone
End Function
‘参考
‘Call SetHttpOnlyCookie(”cookieOnly1″,”onlyValue”,”.gyzs.com”,”/”,0)

%>

http://www.hackbase.com/tech/2009-06-01/53021_2.html