Friday, December 23, 2022

How to use session in Login ASP.NET C#

Passing session value


 Session["AccessType"] = "Institute"


using session value

 if (Session["AccessType"].ToString() == "ReadOnly")

                {

                    linkNewEmployee.Visible = false;

                    linkNewEmployee.Enabled = false;

                }


or



 int UserID = Convert.ToInt32(Session["UserID"]);

            InstituteID = Convert.ToInt32(Session["InstituteId"]);

            if (UserID > 0 || (InstituteID > 0)) { }

            else { Response.Redirect("login.aspx"); }

No comments:

Post a Comment