日期:2014-05-18 浏览次数:20456 次
protected void btn_Click(object sender, EventArgs e) { Response.Cookies["姓名"].Value = "ri"; Response.Redirect("Manager.aspx"); }
public partial class Manager : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Write(Request.Cookies["姓名"].Value); Response.End(); } }
/* 添加cookie */ HttpCookie cookie = new HttpCookie(CookieName); cookie.Value = HttpUtility.UrlEncode(val); if(Day > 0) cookie.Expires = DateTime.Now.AddDays(Day); HttpContext.Current.Response.Cookies.Add(cookie); /* 判断非空 */ (HttpContext.Current.Request.Cookies[cookieName] != null);
------解决方案--------------------
Response.Cookies(“姓名”).Expires
------解决方案--------------------
string Name = mrm.id.ToString();
System.Web.HttpCookie cookie1 = new System.Web.HttpCookie("admin");
cookie1.Expires.AddMinutes(30);
cookie1.Value = mrm.LoginId;
Response.AppendCookie(cookie1);
Response.Redirect("Default.aspx?AHSDS=" + Maticsoft.DBUtility.DESEncrypt.Encrypt(Name) + "");
if (Request.Cookies["admin"] == null)
{
Response.Write("<script>top.location.href='Login.aspx';</script>");
}
else
{
lblMA.Text = Request.Cookies["admin"].Value;
}
你这么用看看