Way to check for cookies

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David C

    Way to check for cookies

    Is there a way to check to see if the browser accepts cookies? I have the
    following line of code that is giving an error "Object reference not set to
    an instance of an object."
    with the following line:

    If Server.HtmlEnco de(Request.Cook ies("level").Va lue) = "admin" Then

    Thanks.
    David


  • gerry

    #2
    Re: Way to check for cookies

    not sure about the VB syntax , in c# it would be something like :

    if ( Request.Cookies["level"]!=null &&
    Server.HtmlEnco de(Request.Cook ies["level"].Value) == "admin" )
    {
    }



    "David C" <dlchase@lifeti meinc.comwrote in message
    news:ujs8aNpRJH A.5348@TK2MSFTN GP02.phx.gbl...
    Is there a way to check to see if the browser accepts cookies? I have the
    following line of code that is giving an error "Object reference not set
    to an instance of an object."
    with the following line:
    >
    If Server.HtmlEnco de(Request.Cook ies("level").Va lue) = "admin" Then
    >
    Thanks.
    David
    >
    >

    Comment

    • David C

      #3
      Re: Way to check for cookies

      Just curious. Why do you use Request.Cookies in one stmt and
      Server.HtmlEnco de(Request.Cook ies... in another? Are they equivalent?

      David
      "gerry" <germ2@newsgrou p.nospamwrote in message
      news:O9JXqmpRJH A.588@TK2MSFTNG P06.phx.gbl...
      not sure about the VB syntax , in c# it would be something like :
      >
      if ( Request.Cookies["level"]!=null &&
      Server.HtmlEnco de(Request.Cook ies["level"].Value) == "admin" )
      {
      }
      >
      >
      >
      "David C" <dlchase@lifeti meinc.comwrote in message
      news:ujs8aNpRJH A.5348@TK2MSFTN GP02.phx.gbl...
      >Is there a way to check to see if the browser accepts cookies? I have
      >the following line of code that is giving an error "Object reference not
      >set to an instance of an object."
      >with the following line:
      >>
      >If Server.HtmlEnco de(Request.Cook ies("level").Va lue) = "admin" Then
      >>
      >Thanks.
      >David
      >>
      >>
      >
      >

      Comment

      • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

        #4
        Re: Way to check for cookies

        in c# if are short circuited

        if (a && b)

        if a is false, b will not be evaluated. this is not tue for vb, you will
        need to do two if statements. assuming i can remember vb syntax at all:

        If not Request.Cookies ("level") is nothing then
        if Server.HtmlEnco de(Request.Cook ies("level").Va lue) = "admin" Then

        end if
        end if

        also have no idea why you call Server.HtmlEnco de().

        -- bruce (sqlwork.com)


        "David C" wrote:
        Just curious. Why do you use Request.Cookies in one stmt and
        Server.HtmlEnco de(Request.Cook ies... in another? Are they equivalent?
        >
        David
        "gerry" <germ2@newsgrou p.nospamwrote in message
        news:O9JXqmpRJH A.588@TK2MSFTNG P06.phx.gbl...
        not sure about the VB syntax , in c# it would be something like :

        if ( Request.Cookies["level"]!=null &&
        Server.HtmlEnco de(Request.Cook ies["level"].Value) == "admin" )
        {
        }



        "David C" <dlchase@lifeti meinc.comwrote in message
        news:ujs8aNpRJH A.5348@TK2MSFTN GP02.phx.gbl...
        Is there a way to check to see if the browser accepts cookies? I have
        the following line of code that is giving an error "Object reference not
        set to an instance of an object."
        with the following line:
        >
        If Server.HtmlEnco de(Request.Cook ies("level").Va lue) = "admin" Then
        >
        Thanks.
        David
        >
        >
        >
        >
        >

        Comment

        • David C

          #5
          Re: Way to check for cookies

          I was probably brain dead when I coded this page. Normally I just use
          If Not Request.Cookies ("level") Is Nothing Then
          ....

          David
          "bruce barker" <brucebarker@di scussions.micro soft.comwrote in message
          news:1BCBAE50-14AE-4D2C-80D5-87A5A77EC12C@mi crosoft.com...
          in c# if are short circuited
          >
          if (a && b)
          >
          if a is false, b will not be evaluated. this is not tue for vb, you will
          need to do two if statements. assuming i can remember vb syntax at all:
          >
          If not Request.Cookies ("level") is nothing then
          if Server.HtmlEnco de(Request.Cook ies("level").Va lue) = "admin" Then
          >
          end if
          end if
          >
          also have no idea why you call Server.HtmlEnco de().
          >
          -- bruce (sqlwork.com)
          >
          >
          "David C" wrote:
          >
          >Just curious. Why do you use Request.Cookies in one stmt and
          >Server.HtmlEnc ode(Request.Coo kies... in another? Are they equivalent?
          >>
          >David
          >"gerry" <germ2@newsgrou p.nospamwrote in message
          >news:O9JXqmpRJ HA.588@TK2MSFTN GP06.phx.gbl...
          not sure about the VB syntax , in c# it would be something like :
          >
          if ( Request.Cookies["level"]!=null &&
          Server.HtmlEnco de(Request.Cook ies["level"].Value) == "admin" )
          {
          }
          >
          >
          >
          "David C" <dlchase@lifeti meinc.comwrote in message
          news:ujs8aNpRJH A.5348@TK2MSFTN GP02.phx.gbl...
          >Is there a way to check to see if the browser accepts cookies? I have
          >the following line of code that is giving an error "Object reference
          >not
          >set to an instance of an object."
          >with the following line:
          >>
          >If Server.HtmlEnco de(Request.Cook ies("level").Va lue) = "admin" Then
          >>
          >Thanks.
          >David
          >>
          >>
          >
          >
          >>
          >>
          >>

          Comment

          Working...