zoukankan      html  css  js  c++  java
  • Cookies

    /// <summary>
    /// 添加Cookies操作
    /// <param name="cookieName">名称</param>
    /// <param name="wrod">值</param>
    /// </summary>
    public static void AddCookie(string cookieName, string value)
    {
    if ("" == cookieName.Trim() || string.Empty == cookieName || null == cookieName)
    {
    return;
    }
    if ("" == value.Trim() || string.Empty == value || null == value)
    {
    return;
    }
    HttpCookie Cookies = new HttpCookie(cookieName);
    Cookies.Value = value;
    Cookies.HttpOnly = false;//该COOKIE是否可以被客户端脚本调用
    Cookies.Expires = DateTime.Now.AddDays(1);
    HttpContext.Current.Response.Cookies.Set(Cookies);
    }
    /// <summary>
    /// 获得本地Cookies 里面存放的是单值
    /// </summary>
    /// <returns></returns>
    public static string GetCookie(string cookieName)
    {
    if (null == cookieName || "" == cookieName.Trim() || string.Empty == cookieName)
    {
    return "";
    }
    if (null == HttpContext.Current.Request.Cookies[cookieName] || HttpContext.Current.Request.Cookies[cookieName].Value.ToString() == "")/****判断当前的对象是否为空****/
    {
    return "";
    }
    else
    {
    return HttpContext.Current.Request.Cookies[cookieName].Value.ToString();
    }
    }

  • 相关阅读:
    loadrunner 录制login(关联 参数化 检查点)
    nmon安装(转)
    理解Load Average做好压力测试
    内存泄漏
    上下文切换
    Jmeter 多台机器产生负载
    Java jvm 原理
    【转】HTML-based script和URL-based script两种脚本录制方式
    cookie模拟
    startUML破解方式
  • 原文地址:https://www.cnblogs.com/Rock-Lee/p/3239372.html
Copyright © 2011-2022 走看看