private bool GenerateSessionForAdmin() { string userCookies = ""; string userSession = ""; if (HttpContext.Current.Request.Cookies["CK_KP_User_Id"] != null) { userCookies = (string)HttpContext.Current.Request.Cookies["CK_KP_User_Id"].Value; } if (HttpContext.Current.Session["KP_User_Id"] != null) { userSession = HttpContext.Current.Session["KP_User_Id"].ToString(); } if (userSession == null || userSession == "") { if (userCookies != null && userCookies != "") { using (LoginGateway objAdmin = new LoginGateway()) { DataTable dtAdmin = objAdmin.Show_AllUsers(Convert.ToInt32(userCookies)); if (dtAdmin.Rows.Count > 0) { HttpContext.Current.Session["KP_User_Id"] = dtAdmin.Rows[0]["UserId"].ToString(); HttpContext.Current.Session["KP_Name"] = dtAdmin.Rows[0]["FullName"].ToString(); HttpContext.Current.Session["KP_UserName"] = dtAdmin.Rows[0]["UserName"].ToString(); HttpContext.Current.Response.Cookies["CK_KP_User_Id"].Expires = DateTime.Now.AddDays(7); return(true); } else { return(false); } } } else { return(false); } } else { return(true); } }