zoukankan      html  css  js  c++  java
  • 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);
            }

  • 相关阅读:
    ceph 网络配置
    Centos7.2 下DNS+NamedManager高可用部署方案完整记录
    Mysql多实例数据库
    Mysql 基础
    搭建本地YUM仓库
    Go实现线程安全的缓存
    KubeEdge安装详细教程
    Kubeedge实现原理
    Go语言中new()和make()的区别
    Go语言中append()函数的源码实现在哪里?
  • 原文地址:https://www.cnblogs.com/zqn518/p/2380380.html
Copyright © 2011-2022 走看看