• cookie使用汇总 c设置ookie的生命周期


    protected void btnSearch_Click(object sender, EventArgs e)
            
    {
                //生成条件表达式
                string where = bll.GetWhereSql(Int32.Parse(ddlCate.SelectedValue),
                            Int32.Parse(ddlHarbor.SelectedValue), 00, ddlState.SelectedValue, tbKeyword.Text.Trim());
                //判断条件Cookie是否为空,如不为空,则移除现有条件Cookie
                if (Request.Cookies["Admin_HarborSpot_Where"] != null)
                {
                    RemoveWhereCookie(where);//移除现有条件Cookie
                }

                //设置一个新的条件Cookie
                SetWhereCookie(where);
                
                BindData(true);
            }


    //设置条件Cookie
            private void SetWhereCookie(string where)
            
    {
                HttpCookie cookie = new HttpCookie("Admin_HarborSpot_Where");
                cookie.Value = where;
                cookie.Expires = DateTime.Now.AddDays(1d);
                Response.Cookies.Add(cookie);
            }


            
    //移除现存的条件Cookie
            private void RemoveWhereCookie(string where)
            
    {
                HttpCookie cookie = Request.Cookies["Admin_HarborSpot_Where"];
                cookie.Value = where;
                cookie.Expires = DateTime.Now.AddDays(-3d);
                Response.Cookies.Add(cookie);
            }

  • 相关阅读:
    字符串哈希
    codeforces#766 D. Mahmoud and a Dictionary (并查集)
    莫比乌斯反演模板
    马拉车模板
    codeforces#580 D. Kefa and Dishes(状压dp)
    1076E
    448C
    543A
    295B
    poj3974 Palindrome
  • 原文地址:https://www.cnblogs.com/zqn518/p/2380380.html
Copyright © 2020-2023  润新知