A simple way to solve this problem is using authentication process in login page and checking authentication details in pages from AdminHome, Student, Teacher at page load.
When authentication is successful in login page, redirect user as per role to corresponding folder/page. Before redirecting, save required user credentials in session and cookie variables. Then cross check user at related pages in above mentioned folder using this values from session and cookies. If you are using master page, then you need to check required authentication details only once in master page load event. If user details does not match, simply redirect user to either login page or home page.
Following code snippet is used for login;
Session["DynamicID"] = dynamic_id;
Session["EmailID"] = txtbx_EmailID.Text.Trim();
Session["DispName"] = GetDispName();
app_cookie = new HttpCookie("App", dynamic_id);
Response.AppendCookie(app_cookie);
Response.RedirectPermanent("~/Dept/Default.aspx",true);
Following code block is used at master page load event;
ses_autoid = Session["DynamicID"].ToString();
cook_autoid = Request.Cookies.Get("App").Value.ToString();
if (ses_autoid == cook_autoid)
{
Label_User.Text = "Display name: " + Session["DispName"].ToString();
Label_User1.Text = Session["DispName"].ToString();
}
else {
Response.RedirectPermanent("~/Common/LogOut.aspx", true);
}