Friday, March 19, 2021

Session Login in c# or Cookies Login in c#

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

Convert 1.25x speed spent hours convert into normal (1x) speed spent hours

If I run a video with 1.25x or 125% speed till 1 hour 26 minuts, then normal hours will be ?   1 hours 26 minuts convert into hours Total 60...