zoukankan      html  css  js  c++  java
  • 关于Cookie

    1、 创建cookie
        

    /// <summary>
            /// 创建cookie
            /// </summary>
            /// <param name="key"></param>
            /// <param name="value"></param>
            public static void CreateCookie(string childCookie, string value)
            {
                if (HttpContext.Current.Request.Cookies["LoanAssess"] != null && HttpContext.Current.Request.Cookies["LoanAssess"].Value != "")
                {
                    HttpCookie cookies = HttpContext.Current.Request.Cookies["LoanAssess"];
                    cookies.Values[childCookie] = value;
                    cookies.Expires = DateTime.Now.AddDays(1);
                    HttpContext.Current.Response.AppendCookie(cookies);
                }
                else
                {
                    HttpCookie newcookie = new HttpCookie("LoanAssess");
                    newcookie.Values[childCookie] = value;
                    newcookie.Expires = DateTime.Now.AddDays(1);
                    HttpContext.Current.Response.AppendCookie(newcookie);
                }
            }
    View Cod


     2、得到cookie值
            

    /// <summary>
            /// 得到cookie值
            /// </summary>
            /// <param name="childKey">子键cookie</param>
            /// <returns></returns>
            public static string GetCookieValue(string childKey)
            {
                string cookieValue = "";
                HttpCookie cookies = HttpContext.Current.Request.Cookies["LoanAssess"];
                if (cookies != null && cookies.Values[childKey] != null)
                {
                    cookieValue = cookies.Values[childKey];
                }
                return HttpUtility.UrlDecode(cookieValue);
            }
    View Code
  • 相关阅读:
    2016.10.09
    Httpie 进行web请求模拟
    Python-集合
    python-字典
    MySQL权限系统
    MySQL8.0安装以及介绍(二进制)
    数据库对象中英文介绍
    Python-字符串
    GIT安装部署
    Cobbler安装部署
  • 原文地址:https://www.cnblogs.com/eric-gms/p/4054462.html
Copyright © 2011-2022 走看看