zoukankan      html  css  js  c++  java
  • Cookie帮助类

    using System;

    using System.Collections.Generic;

    using System.Text;

    using System.Web;

    namespace AIMSCommon

    {    

    /// <summary>    

    /// Cookie帮助类    

    /// </summary>    

    public class CookieHelper    

    {        

    /// <summary>        

    /// 写cookie值        

    /// </summary>        

    /// <param name="strName">名称</param>        

    /// <param name="strValue">值</param>        

    public static void WriteCookie(string strName, string strValue)       

      {            

    HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];             if (cookie == null)             {                 cookie = new HttpCookie(strName);             }             cookie.Value = strValue;             HttpContext.Current.Response.AppendCookie(cookie);

            }         /// <summary>         /// 写cookie值         /// </summary>         /// <param name="strName">名称</param>         /// <param name="strValue">值</param>         /// <param name="strValue">过期时间(分钟)</param>         public static void WriteCookie(string strName, string strValue, int expires)         {             HttpCookie cookie = HttpContext.Current.Request.Cookies[strName];             if (cookie == null)             {                 cookie = new HttpCookie(strName);             }             cookie.Value = strValue;             cookie.Expires = DateTime.Now.AddMinutes(expires);             HttpContext.Current.Response.AppendCookie(cookie);

            }

            /// <summary>         /// 读cookie值         /// </summary>         /// <param name="strName">名称</param>         /// <returns>cookie值</returns>         public static string GetCookie(string strName)         {             if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[strName] != null)             {                 return HttpContext.Current.Request.Cookies[strName].Value.ToString();             }             return "";         }     } }

  • 相关阅读:
    Java并发包中Lock的实现原理
    多线程---再次认识volatile,Synchronize,lock
    共享锁(S锁)和排它锁(X锁)
    Java 7中的TransferQueue 以及 SynchronousQueue
    精巧好用的DelayQueue
    非阻塞同步算法与CAS(Compare and Swap)无锁算法
    彻底理解线索二叉树
    使用import取代require
    子页面iframe跨域执行父页面定义的JS方法
    利用js实现 禁用浏览器后退
  • 原文地址:https://www.cnblogs.com/zhangxiaolei521/p/5660687.html
Copyright © 2011-2022 走看看