protected void LoginButton_Click(object sender, EventArgs e)
{
string username = NameTextBox.Text;
HttpCookie cookie = new HttpCookie("UserInfo");
cookie["Username"] = username;
cookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(cookie);
}
Retrieving information
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie cookie = Request.Cookies["UserInfo"];
if(cookie!=null)
{
string username = cookie["Username"];
if (username != null)
{
Response.Redirect("OrderPage.aspx?Username=" + username);
return;
}
}
Response.Redirect("Login.aspx");
}
No comments:
Post a Comment