应该是SetCookie("RFieldName","this is red")吧<script>
function SetCookie (name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
SetCookie("RFieldName","this is red")
alert(document.cookie);
</script>
function SetCookie (name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}
SetCookie("RFieldName","this is red")
alert(document.cookie);
</script>
echo $HTTP_COOKIE_VARS["RFieldName"];
不行呀.如果我定義的是:
SetCookie("RFieldName",旭基石碣");
它顯示的結果是:%u87BA%u67F1%u5716%u9762.
echo urldecode($HTTP_COOKIE_VARS["RFieldName"]);
<script language="vbscript">
function urlencoding(vstrin)
dim i,strreturn
strreturn = ""
for i = 1 to len(vstrin)
thischr = mid(vstrin,i,1)
if abs(asc(thischr)) < &hff then
strreturn = strreturn & thischr
else
innercode = asc(thischr)
if innercode < 0 then
innercode = innercode + &h10000
end if
hight8 = (innercode and &hff00)\ &hff
low8 = innercode and &hff
strreturn = strreturn & "%" & hex(hight8) & "%" & hex(low8)
end if
next
urlencoding = strreturn
end function
</script>
示例:
<script language=javascript>
document.write(urlencoding("中国"));
</script>这样可以urldecode
<?
die(urldecode("%D6%D0%B9%FA"));
?>