I have a function that checks if a cookie exists (by name):
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
I have a class that processes cookies depending on the application, and I want to combine all the cookie related functions for this class. However, I cannot use this code if I simply move it from the aspx page (where it is currently) to the aforementioned class, because I get the error: 'Name' Response is not declared.I modified the class to allow the link to be passed to : Response
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
My question is: is there a better way?
source
share