How do I check to see if a cookie exists or not?

I tried these 3 but they don't work...

If Not Request.Cookies("UserSettings")("IsAdmin") Is Nothing Then...
If Request.Cookies("UserSettings")("IsAdmin") IsNot Nothing Then...
If Not IsNothing(Request.Cookies("UserSettings")("IsAdmin")) Then...

They all give me a System.NullReferenceException.

Thanks!

RE: How to check if cookie not exist? by brucebarker

brucebarker
Wed Mar 12 15:39:00 CDT 2008

If Not Request.Cookies("UserSettings") Is Nothing Then
If Not Request.Cookies("UserSettings")("IsAdmin") Is Nothing Then
...
end if
end if


-- bruce (sqlwork.com)


"Bobby Edward" wrote:

> How do I check to see if a cookie exists or not?
>
> I tried these 3 but they don't work...
>
> If Not Request.Cookies("UserSettings")("IsAdmin") Is Nothing Then...
> If Request.Cookies("UserSettings")("IsAdmin") IsNot Nothing Then...
> If Not IsNothing(Request.Cookies("UserSettings")("IsAdmin")) Then...
>
> They all give me a System.NullReferenceException.
>
> Thanks!
>
>
>