andrew4582

Cookie Methods ASP.NET

Aug 15th, 2010
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1.     protected bool GetRequestCookie (string name, out string value) {
  2.         value = null;
  3.         if (!Request.Browser.Cookies)
  4.             return false;
  5.        
  6.         HttpCookie cook = Request.Cookies[name];
  7.         if (cook != null) {
  8.             value = cook.Value;
  9.             return true;
  10.         }
  11.         value = null;
  12.         return false;
  13.     }
  14.     protected HttpCookie SetResponseCookie (string name, string value) {
  15.         if (!Request.Browser.Cookies)
  16.             return null;
  17.         HttpCookie cook = new HttpCookie (name, value);
  18.         cook.Expires = DateTime.Now.AddYears (10);
  19.         Response.SetCookie (cook);
  20.         return cook;
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment