yangtu86

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

/// <summary>
  
/// 设置cookies并且加密,无返回值
  
/// </summary>

  public void SetCookies(string name,string values)
  
{
   HttpCookie cookie 
= new HttpCookie(name);
   
string str=ssg.SetString(values);
   cookie.Value 
= str;
   System.Web.HttpContext.Current.Response.AppendCookie(cookie);

  }


  
/// <summary>
  
/// 获得cookies值后解密,cookies存在则返回string。cookies不存在则返回为null
  
/// </summary>

  public string GetCookies(string name)
  
{
   
if(System.Web.HttpContext.Current.Request.Cookies[name]!=null)
   
{
    HttpCookie cookie 
= System.Web.HttpContext.Current.Request.Cookies[name];
    
return ssg.GetString(cookie.Value);
   }

   
else
   
{
    
return null;
   }

  }


  
/// <summary>
  
/// 判断某cookies是否存在,存在返回true,不存在返回false
  
/// </summary>

  public bool CookiesIsExist(string name)
  
{
   
if(System.Web.HttpContext.Current.Request.Cookies[name]!=null)
   
{
    
return true;
   }

   
else
   
{
    
return false;
   }

  }

posted on 2006-11-27 16:03  杨土  阅读(544)  评论(1编辑  收藏  举报