Detect if Cookies are enabled

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • splendid9
    New Member
    • Mar 2008
    • 56

    Detect if Cookies are enabled

    Is there any way to detect if the cookies are enabled in the browser for am ASP.net page. please reply me asap.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    I think you can use javascript to detect if cookies are allowed?

    Comment

    • splendid9
      New Member
      • Mar 2008
      • 56

      #3
      yea i got code in javascript to chk if thr browser supports, but i want to chk if the cookies are enabled and moreover if i try with javascript even that must be enabled in the browser.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        I think they only way to find out is to try and see if they work.
        There's not really any identifying protocal that you can rely on to find out.

        Comment

        • splendid9
          New Member
          • Mar 2008
          • 56

          #5
          Actually here is my probelm, first comes the login page and when trying to login blocking cookies it takes to another page where there is a agreement and have two buttons 'iagree' & 'cancel', Hitting iagree refreshes the page and hitting cancel logs off from the site taking back to login page.I want to chck if cookies enabled in the login button click and if so pop up one alert asking to enable cookies, if they r enabled, normal functioning.... .......but i cud not keep it in the login button click,i have tried many methods none of them are of use,.could you or anyone can help me out with this.


          Thanks.

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            The javascript should work.
            If they block javascript, NONE of your asp.net functions will work, since it's all based on javascript.

            Comment

            • splendid9
              New Member
              • Mar 2008
              • 56

              #7
              ok cud u tell me where to place this javascript and also i found different scripts for the same problem, cud yu tell me which will work correctly.

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                Add it to the onload event of the body element?
                I'm sure any of the scripts you find on the web would work fine.

                Comment

                • splendid9
                  New Member
                  • Mar 2008
                  • 56

                  #9
                  Hi i have tried this
                  if(navigator.co okieEnabled)
                  {
                  alert('yes');
                  }
                  else
                  {
                  alert('no');
                  }
                  on the onload of my page........... ....but donno y am getting corret re4sult in firefox but not in IE..even if i disable cookies i am getting 'yes'.......... .....?????????? ? cud u help me with this,.?ASAP

                  Comment

                  • splendid9
                    New Member
                    • Mar 2008
                    • 56

                    #10
                    Cookies

                    Hi i have tried this to detect if cookies are enabled........ ...........
                    if(navigator.co okieEnabled)
                    {
                    alert('yes');
                    }
                    else
                    {
                    alert('no');
                    }
                    on the onload of my page........... ....but donno y am getting corret result in firefox but not in IE..even if i disable cookies i am getting 'yes'.......... .....?????????? ? cud u help me with this,.?ASAP

                    --------------------------------------------------------------------------------

                    Comment

                    • Curtis Rutland
                      Recognized Expert Specialist
                      • Apr 2008
                      • 3264

                      #11
                      Real's HowTo : Useful code snippets for Java, JS, PB and more


                      This article should help.

                      Originally posted by splendid9
                      Hi i have tried this to detect if cookies are enabled........ ...........
                      if(navigator.co okieEnabled)
                      {
                      alert('yes');
                      }
                      else
                      {
                      alert('no');
                      }
                      on the onload of my page........... ....but donno y am getting corret result in firefox but not in IE..even if i disable cookies i am getting 'yes'.......... .....?????????? ? cud u help me with this,.?ASAP

                      --------------------------------------------------------------------------------

                      Comment

                      • Plater
                        Recognized Expert Expert
                        • Apr 2007
                        • 7872

                        #12
                        Navigator is generally a mozilla-specific keyword (mozilla/netscape/firefox)

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #13
                          Originally posted by Plater
                          Navigator is generally a mozilla-specific keyword (mozilla/netscape/firefox)
                          Navigator is a JavaScript object containing information about the client browser - see http://www.w3schools.com/htmldom/dom_obj_navigator.asp.

                          PS. Moved to JavaScript forum,
                          Moderator.

                          Comment

                          • Plater
                            Recognized Expert Expert
                            • Apr 2007
                            • 7872

                            #14
                            Huh. Oops. I've never seen it reference before outside of netscape-specific javascripting.

                            Comment

                            • acoder
                              Recognized Expert MVP
                              • Nov 2006
                              • 16032

                              #15
                              You may be confused with Netscape Navigator (browser name).

                              Comment

                              Working...