//写
HttpCookie cookie1 = new HttpCookie("LoginIdCookie");
cookie1.Values.Add("LoginId",dt.Rows[0]["Id"].ToString());
Response.AppendCookie(cookie1);
//读
HttpCookie cookie2 = Request.Cookies["LoginIdCookie"];
string LoginId=cookie2.Values["LoginId"].ToString();
Response.Write("上次访问时间是:"+LoginId);
<script language="C#" type="text/javascript" runat="server"> public int TotalCount=0; private void Page_Load(Object sender,EventArgs e){ //写 HttpCookie cookie1 = new HttpCookie("MyCookie"); cookie1.Values.Add("theFirst",System.DateTime.UtcNow.ToString()); cookie1.Expires = DateTime.Now.Add(new TimeSpan(0,24,0,0)); Response.AppendCookie(cookie1); //读 HttpCookie cookie2 = Request.Cookies["MyCookie"]; string PassDate=cookie2.Values["theFirst"].ToString(); Response.Write("上次访问时间是:"+PassDate); } </script>
<%@ Page Language="C#" ContentType="text/html"%>
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<script language="C#" runat="server">
public int TotalCount=0;
private void Page_Load(Object sender,EventArgs e){
//写
HttpCookie cookie1 = new HttpCookie("MyCookie");
cookie1.Values.Add("theFirst",System.DateTime.UtcNow.ToString());
cookie1.Expires = DateTime.Now.Add(new TimeSpan(0,24,0,0));
Response.AppendCookie(cookie1);
//读
HttpCookie cookie2 = Request.Cookies["MyCookie"];
string PassDate=cookie2.Values["theFirst"].ToString();
Response.Write("上次访问时间是:"+PassDate);
}
</script>
<script language="C#" type="text/javascript" runat="server"> public int TotalCount=0; private void Page_Load(Object sender,EventArgs e){ //写 HttpCookie cookie1 = new HttpCookie("MyCookie"); cookie1.Values.Add("theFirst",System.DateTime.UtcNow.ToString()); cookie1.Expires = DateTime.Now.Add(new TimeSpan(0,24,0,0)); Response.AppendCookie(cookie1); //读 HttpCookie cookie2 = Request.Cookies["MyCookie"]; string PassDate=cookie2.Values["theFirst"].ToString(); Response.Write("上次访问时间是:"+PassDate); } </script>
<script language="C#" type="text/javascript" runat="server"> public int TotalCount=0; private void Page_Load(Object sender,EventArgs e){ //写 HttpCookie cookie1 = new HttpCookie("MyCookie"); cookie1.Values.Add("theFirst",System.DateTime.UtcNow.ToString()); cookie1.Expires = DateTime.Now.Add(new TimeSpan(0,24,0,0)); Response.AppendCookie(cookie1); //读 HttpCookie cookie2 = Request.Cookies["MyCookie"]; string PassDate=cookie2.Values["theFirst"].ToString(); Response.Write("上次访问时间是:"+PassDate); } </script>
发表于 @ 2005年08月05日 10:23:00|评论(0 <script type="text/javascript">AddFeedbackCountStack("446318")</script> )|编辑