首先添加using System.Web.SessionState引用。
这样发送信息:
HttpCookie cookie = new HttpCookie("UserCookie");
cookie.Values.Add("UserName",tbName.Text);
cookie.Values.Add("UserPassword",tbPassword.Value.ToString());
cookie.Values.Add("UserRole",ds.Tables["Users"].Rows[0]["Role"].ToString());
Response.AppendCookie(cookie);
Response.Redirect("MainPage.aspx");
这样接受信息:
string sName= Request.Cookies["UserCookie"].Values["UserName"].ToString();
string sRole = Request.Cookies["UserCookie"].Values["UserRole"].ToString();
本文地址:http://com.8s8s.com/it/it44155.htm