1. Cookies
public ActionResult Login(){
Response.Cookies["userc"].Value = log.user_name;
return RedirectToAction("Index");
}
public ActionResult Logout(){
Response.Cookies["userc"].Value = "";
return RedirectToAction("Index");
}
public ActionResult Using(){
if (Request.Cookies["userc"] != null && Request.Cookies["userc"].Value != ""){
string var1 = Request.Cookies["userc"].Value;
}
return RedirectToAction("Index");
}
2. Session
public ActionResult Login(){
Session["user_id"] = log.user_name;
return RedirectToAction("Index");
}
public ActionResult Logout(){
Session["user_id"] = null;
return RedirectToAction("Index");
}
public ActionResult Using(){
if (Session["user_id"] != null){
string var1 = Session["user_id"].ToString();
}
return RedirectToAction("Index");
}
No comments:
Post a Comment