User Management With help of Session in three steps.

Step 1. On login page when userid and password is correct then before redirect to next page write this code...

Session["client"] = TxtUsername.Text;
or
Session["admin"] = TxtUsername.Text;

Step 2. On each page in page_load or if you are using master page then master page's page load write these code...

if (Session["client"] == null)
{
    Response.Redirect("../Default.aspx"); //where default.aspx page is login page.
}

or

if (Session["admin"] == null)
{
    Response.Redirect("../Default.aspx"); //where default.aspx page is login page.
}

It will restrict a unauthorized jump of pages (No client user can see admin pages and no admin page can go to client's page.)

And also restrict unauthenticated users to jump to a page without login.

Step 3. When a person click on logout, before redirect to login page, write these code...where you can put your login page name on place of default.aspx..

Session.Clear();
Response.Redirect("Default.aspx");

I hope your requirement will fulfill with these code.

Ebook Download
View all
Learn
View all