protected void OnLoggedIn(object sender, EventArgs e)
    {
        TextBox UserName = (TextBox)Login1.FindControl("UserName");
        TextBox Password = (TextBox)Login1.FindControl("Password");

        try
        {
            HttpContext.Current.Session["strUserName"] = UserName.Text.ToString().Trim();
            sendOutConfirmationEmail(UserName.Text.ToString().Trim());

            BLL.UserLib oUserLib = new BLL.UserLib();

            Session["strUserType"] = oUserLib.GetRoleNameByUserName(UserName.Text.ToString().Trim());

            Session["ChrUserType"] = oUserLib.GetUserTypeByUser(UserName.Text.ToString().Trim());

            #region Insert visited log details

            AppLib.InsertVisitedSectionDetails("Logged In");

            #endregion

            oUserLib = null;

            BLL.CompanyManager oCompanyManager;
            Entity.CompanyInfo oCompanyInfo;

            oCompanyManager = new BLL.CompanyManager();
            oCompanyInfo = new Entity.CompanyInfo();

            oCompanyInfo = oCompanyManager.GetCompanyDetailsByEmailId(AppLib.GetLoggedInUserName());
            if (oCompanyInfo != null)
                Session["intLoggedUserId"] = oCompanyInfo.IntCompanyId.ToString();

            oCompanyInfo = null;
            oCompanyManager = null;

            CheckBox cbRememberMe = (CheckBox)Login1.FindControl("cbRememberMe");

            if (cbRememberMe.Checked)
            {
                Response.Cookies.Remove("RememberMe");
                HttpCookie myCookie = new HttpCookie("RememberMe");

                myCookie.Values.Add("Email", UserName.Text.ToString().Trim());

                myCookie.Expires = DateTime.Now.AddDays(200); //you can add years and months too here
                Response.Cookies.Add(myCookie);
            }
            else
            {
                HttpCookie cookie = Request.Cookies["RememberMe"];
                if (cookie != null)
                {
                    cookie.Expires = DateTime.Now.AddDays(-1);
                    Response.Cookies.Add(cookie);
                }
            }
        }
        catch (Exception ex)
        {
        }

        //string sUsername = AppLib.GetLoggedInUserName();
        string sUsername = Membership.GetUser(UserName.Text.Trim()).UserName;

        try
        {
            if (objBackofficeClass.Mem_GET_UserInfo(sUsername).Tables[0].Rows[0]["REGISTRATION_FLG"].ToString() == "0")
            {//they have not gone through their personal registration yet

                FormsAuthentication.SignOut();// LOG USER OUT PROGRAMMATICALLY
                //Response.Redirect("/Main/UserUtilities/EditUser.aspx?username="******"Main/UserUtilities/EditUser.aspx?username="******"Password"))
            {
                //Response.Redirect("/Anonymous/ResetPassword/ResetPassword.aspx");/*Commented by Netsmartz*/

                Response.Redirect(AppConfig.GetBaseSiteUrl() + "Anonymous/ResetPassword/ResetPassword.aspx");
            }
            else if (Roles.IsUserInRole(sUsername, "Company"))
            {
                //Response.Redirect("/Anonymous/ResetPassword/ResetPassword.aspx");/*Commented by Netsmartz*/

                Response.Redirect(AppConfig.GetBaseSiteUrl() + "Company/UploadUsersForRegistration.aspx");
            }
        }
        catch (Exception ex)
        {
        }

        /*---------------------VISITLOG---------------------*/
         //   UC_Visitlog_Visitlog1.addEntry(1, 0, 0, 0, "", "", "");

        Response.Redirect(AppConfig.GetBaseSiteUrl() + "login/login_success.aspx");
    }