Copy codeThe Code is as follows:
<%
Response. Cookies ("Cookie1") ("key1") = "KeyValue2"
%>
<Script language = "javascript">
String. prototype. get = function (name ){
Var reg = new RegExp ("(^ | & | \\?) "+ Name +" = ([^ &] *) (& | $) "), r;
If (r = this. match (reg ))
Return unescape (r [2]);
Return null;
}
// Obtain and return the cookie value
// Case insensitive for cookieName
// DfltValue is the default Return Value
// Do not consider the subkey
Function RequestCookies (cookieName)
{
Var lowerCookieName = cookieName. toLowerCase ();
Var cookieStr = document. cookie;
If (cookieStr = "") return "";
Var cookieArr = cookieStr. split (";");
Var pos =-1;
For (var I = 0; I <cookieArr. length; I ++ ){
Pos = cookieArr [I]. indexOf ("= ");
If (pos> 0 ){
If (cookieArr [I]. substring (0, pos). toLowerCase () = lowerCookieName)
{
Return unescape (cookieArr [I]. substring (pos + 1, cookieArr [I]. length ));
}
}
}
Return "";
}
Document. write ("read cookies named AB..." + RequestCookies ("Cookie1"). get ("key1 "));
-->
</Script>