asp.net 写入cookie
HttpCookie cookie = new HttpCookie("uid");
cookie.Value = uid;
Response.AppendCookie(cookie);
HttpCookie cookie1 = new HttpCookie("gid");
cookie1.Value = gid;
Response.AppendCookie(cookie1);
js读取cookie
<script>
function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
function aa() {
var uid= getCookie("uid");
alert(uid);
}
</script>