How to check if cookie not exist?

Discussion in 'ASP .Net' started by Bobby Edward, Mar 12, 2008.

  1. Bobby Edward

    Bobby Edward Guest

    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!
    Bobby Edward, Mar 12, 2008
    #1
    1. Advertising

  2. Bobby Edward

    bruce barker Guest

    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!
    >
    >
    >
    bruce barker, Mar 12, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Y.S.
    Replies:
    3
    Views:
    984
    strajan
    Sep 17, 2003
  2. LT
    Replies:
    7
    Views:
    2,074
    Phlip
    Jul 25, 2004
  3. praba kar
    Replies:
    1
    Views:
    399
    Michael Hoffman
    Apr 9, 2005
  4. Sidharth Kuruvila
    Replies:
    0
    Views:
    3,072
    Sidharth Kuruvila
    Apr 9, 2005
  5. Markus Mohr
    Replies:
    7
    Views:
    228
    Thomas 'PointedEars' Lahn
    Nov 28, 2003
Loading...

Share This Page