Пример #1
0
 protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
 {
     if (Request.Cookies["Cookies"] != null)
     {
         HttpCookie mycookies = new HttpCookie("Cookies");
         mycookies["u_id"] = null;
         mycookies.Expires = DateTime.Now.AddDays(-1d);
         Response.Cookies.Add(mycookies);
         SSOHelper.GlobalSessionEnd();
     }
 }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        txt_UserName.Focus();

        if (!Page.IsPostBack)
        {
            if (Request.QueryString["function"] != null)
            {
                string code        = "";
                string codecompare = System.Configuration.ConfigurationManager.AppSettings["LoginCode"].ToString();
                try
                {
                    code = DESEncrypt.Decrypt(Request.QueryString["function"]).ToString();
                }
                catch
                {
                    string encode = DESEncrypt.Encrypt(codecompare);
                }
                if (code == codecompare)
                {
                    string strSql = "select DepartID,UserID,t_R_UserInfo.RoleID,PWDModifyTime,Name,LevelID,ReadRight,WriteRight,RefreshRight,FileRight,id from t_R_UserInfo inner join t_R_Role on t_R_Role.RoleID=t_R_UserInfo.RoleID where UserID='user' and PWD='user'";

                    //
                    // string strSql = "select id,UserID,t_R_UserInfo.RoleID,Name,RealName,PWDModifyTime,LevelID,ReadRight,WriteRight,RefreshRight,id from t_R_UserInfo inner join t_R_Role on t_R_Role.RoleID=t_R_UserInfo.RoleID where UserID='user' and PWD='user'";
                    MyDataOp mdo = new MyDataOp(strSql);
                    DataSet  ds  = mdo.CreateDataSet();

                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        Response.Write("<script language='javascript'>alert('帐户或密码输入错误!请重新输入!');</script>");
                    }
                    else
                    {
                        HttpCookie Cookie = new HttpCookie("Cookies");

                        DateTime dt = DateTime.Now;
                        TimeSpan ts = new TimeSpan(0, 10, 0, 0); //有效期10小时;
                        Cookie.Expires = dt.Add(ts);
                        Cookie.Values.Add("uid", ds.Tables[0].Rows[0]["id"].ToString());
                        Cookie.Values.Add("u_id", ds.Tables[0].Rows[0]["UserID"].ToString());
                        Cookie.Values.Add("Name", HttpUtility.UrlEncode(ds.Tables[0].Rows[0]["Name"].ToString()));
                        // Cookie.Values.Add("RealName", HttpUtility.UrlEncode(ds.Tables[0].Rows[0]["RealName"].ToString()));
                        Cookie.Values.Add("u_role", ds.Tables[0].Rows[0]["RoleID"].ToString());
                        Cookie.Values.Add("u_level", ds.Tables[0].Rows[0]["LevelID"].ToString());
                        Cookie.Values.Add("u_purview", ds.Tables[0].Rows[0]["ReadRight"].ToString() + //读权限
                                          ds.Tables[0].Rows[0]["WriteRight"].ToString() +             //写权限
                                          ds.Tables[0].Rows[0]["RefreshRight"].ToString() +
                                          ds.Tables[0].Rows[0]["FileRight"].ToString());              //刷新权限;

                        Response.AppendCookie(Cookie);
                        Response.Redirect("~/main.htm");
                    }
                }
                else
                {
                    Response.Redirect("../Login.aspx");
                }
            }
            else
            {
                txt_UserName.Focus();

                if (!Page.IsPostBack)
                {
                    if (Request.Cookies["Cookies"] != null)
                    {
                        HttpCookie mycookies = new HttpCookie("Cookies");
                        mycookies["u_id"] = null;
                        mycookies.Expires = DateTime.Now.AddDays(-1d);
                        Response.Cookies.Add(mycookies);
                        txt_Pwd.Text = "";
                        SSOHelper.GlobalSessionEnd();
                    }
                }
            }
        }
    }
Пример #3
0
 protected void Session_End(object sender, EventArgs e)
 {
     SSOHelper.GlobalSessionEnd();
 }