Beispiel #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string   name  = Text1.Value;
            string   pass  = Text2.Value;
            Boolean  isok  = false;
            mysql    sql   = new mysql();
            desclass mydes = new desclass();

            if (name == "" || pass == "")
            {
                Label3.Text = "用户名密码不能为空";
            }
            else
            {
                pass = mydes.EnCode(pass);
                pass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pass, "MD5");
                isok = sql.login(name, pass, 1);
                if (isok == false)
                {
                    Label3.Text = "用户名或密码错误";
                }
                else
                {
                    string desname = mydes.EnCode(name);
                    Session["username"] = name;
                    HttpCookie myHttpCookie = new HttpCookie("name", desname);
                    myHttpCookie.HttpOnly = true;
                    Response.AppendCookie(myHttpCookie);
                    Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["localurl"].ToString() + "viewcode.aspx");
                }
            }
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            mysql  sql      = new mysql();
            string username = context.Request["username"];

            Boolean isusname = sql.login(username, "", 2);

            context.Response.Write(isusname);
        }
Beispiel #3
0
        public string yanzheng(string cookie, string sessinname)
        {
            mysql sql = new mysql();

            if (sessinname == "" || sessinname == null)
            {
                if (cookie == "" || cookie == null)
                {
                    return(null);
                }
                else
                {
                    string mycookie = DesDecrypt(cookie);
                    bool   isok     = sql.login(mycookie, "", 3);
                    if (isok == true)
                    {
                        return(mycookie);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            else
            {
                bool isok = sql.login(sessinname, "", 3);
                if (isok == true)
                {
                    return(sessinname);
                }
                else
                {
                    return(null);
                }
            }
        }