protected void Page_Load(object sender, EventArgs e) { try {// this is by logout from system redirect if (Session["SessionUserInfoStore"] != null) { SessionUserInfoStore mySessionUserInfoStore = Session["SessionUserInfoStore"] as SessionUserInfoStore; String mEntityId = mySessionUserInfoStore.UserEntityId; String mSingpassID = mySessionUserInfoStore.UserSingPassId; // TODO: adding logout log } FormsAuthentication.SignOut(); Session.Abandon(); Response.Redirect("~/Default.aspx", false); } catch (System.Exception ex) { throw ex; } }
private void ProcessAuthentication(String aUserId, string aEntityId, string aEntityIdType, string aRolesArrayText, String aUserFullName, String aContactNo, String aEmail) { //Providing the FormsAuthenticationTicket "Ticket" to the authenticated user which contains version, username, entry datetime and expire date time, userdata and cookie path FormsAuthentication.Initialize(); FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, aUserId, DateTime.Now, DateTime.Now.AddMinutes(Session.Timeout), false, aRolesArrayText, FormsAuthentication.FormsCookiePath); //encrypt the ticket and assign it into the string variable "hash" string hash = FormsAuthentication.Encrypt(Ticket); //Response.Cookies.Clear(); HttpCookie Cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash); //checking whether the cookie is constant, If constant then expires the cookie based on the expiration time of user specified in ticket //if (!Ticket.IsPersistent) return; Cookie.Expires = Ticket.Expiration; Response.Cookies.Add(Cookie); Session["SessionUserInfoStore"] = new SessionUserInfoStore(aUserId, aUserId, "Comp", aEntityId, aEntityIdType, aUserFullName, aContactNo, aEmail); Response.Redirect("~/Secure/Course/Courses.aspx", false); }
public String GetLoginCompanyID() { SessionUserInfoStore userInfo = (SessionUserInfoStore)Session["SessionUserInfoStore"]; return(userInfo.UserEntityId); }
public SessionUserInfoStore GetLoginSessionInfo() { SessionUserInfoStore userInfo = (SessionUserInfoStore)Session["SessionUserInfoStore"]; return(userInfo); }