title: Access Response Object in a class ASP.NET
body: <p>I have a function that checks if a cookie (by name) exists or not:</p>
  
  <pre><code>Private Function cookieExists(ByVal cName As String) As Boolean
      For Each c As HttpCookie In Response.Cookies
          If c.Name = cName Then Return True
      Next
      Return False
  End Function
  </code></pre>
  
  <p>I have a class that handles cookies in an application-specific manner, and I want to consolidate all the cookie-related functions to this class.  However, I cannot use this code if I simply move it from the aspx page (where it currently resides) to the aforementioned class because I get the error: <code>'Name' Response is not declared.</code>  I modified the class to allow the passing of a reference to the <strong><code>Response</code></strong> object:</p>
  
  <pre><code>Public Function cookieExists(ByVal cName As String, ByRef Response As HttpResponse) As Boolean
      For Each c As HttpCookie In Response.Cookies
          If c.Name = cName Then Return True
      Next
      Return False
  End Function
  </code></pre>
  
  <p>My question is: Is there a better way?</p>