protected void btnLogin_Click(object sender, EventArgs e)
        {
            UserMidLayer  umt    = new UserMidLayer();
            SqlDataReader reader = umt.Login(txtEmail.Text, txtPWD.Text);

            if (reader.Read())
            {
                Response.Cookies["name"].Value    = reader["name"].ToString();
                Response.Cookies["user_id"].Value = reader["ID"].ToString();

                /*
                 * roles is a colume in the user database to identify if it's
                 * a customer or administer
                 */
                Response.Cookies["roles"].Value = reader["type"].ToString();

                Response.Cookies["name"].Expires    = DateTime.Now.AddDays(10);
                Response.Cookies["user_id"].Expires = DateTime.Now.AddDays(10);
                Response.Cookies["roles"].Expires   = DateTime.Now.AddDays(10);

                reader.Close();
                umt.CloseConnection();
                Response.Redirect("Default.aspx");
            }
            else
            {
                lblLoginError.Text = "Login failed. check your id or password.";
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            UserMidLayer userMidLayer = new UserMidLayer();

            if (userMidLayer.checkEmailExists(txtEmail.Text)) //check if exists
            {
                if (userMidLayer.RegisterUser(txtEmail.Text, txtPWDConfirm.Text, txtName.Text))
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "{Register}", "alert('{Register Successful!}');window.location.href='Login.aspx' ", true);
                    //alert and redirect to login page
                }
                else
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "{error}", "alert('{Register Failed! Contact admin}');window.location.href='Register.aspx' ", true);
                }
            }
            else
            {
                lblRegister.Text = "Email already registered! try another email";
            }
        }