日期:2014-04-26  浏览次数:22881 次

    protected void write_Click(object sender, EventArgs e)//写入Cookies
    {
        HttpCookie cc = new HttpCookie("DDcookies");
        cc.Value = writeCookies.Text;//取得文本框的writeCookies.Text赋给cc.Value
        Response.Cookies.Add(cc);//添加Response.Cookies.Add的值
        Response.Write("<script>alert('COOKIES写入成功了哦,不信你读下!')</script>");
    }
    protected void read_Click(object sender, EventArgs e)//读取Cookies
    {
        HttpCookie rC=Request.Cookies["DDcookies"];
        ReadCookies.Text = rC.Value;
    }
    protected void encrypt_Click(object sender, EventArgs e)
    {
        string strC = writeCookies.Text;
        Response.Cookies["strC"].Value = FormsAuthentication.HashPasswordForStoringInConfigFile(strC, "md5"); //采用MD5加密Cookies的值 
       //要using System.Web.Security;   //援用的命名空间
        encrypCookies.Text = Response.Cookies["strC"].Value.ToString();
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        HttpCookie bb = new HttpCookie("ddd");
        bb.Value=TextBox4.Text;
        Response.Write(bb.Expires);
        Response.Write(bb.Name);
        Response.Write(bb.Path);
        Response.Write(bb.Value);
    }