Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6076531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:37:06+00:00 2026-05-23T10:37:06+00:00

I am adding a feature to a website for my client, showing a div

  • 0

I am adding a feature to a website for my client, showing a div on login page if cookies are disabled. I first started testing this within chrome, turned off cookies, and after

if (document.cookies == "") {
    // show div to tell users cookies are disabled on their machine.
}

everything works. Also in my codebehind on Page_Load i am attempting to set a cookie

protected void Page_Load(object sender, EventArgs e) 
{
    Response.Cookies["test"].Value = "test";
    Response.Cookies["test"].Expires = DateTime.Now.AddDays(1);
}

All seems well in chrome land. Next, I go over to IE7, block all cookies, and for safety sake, delete all my history and cookies just in case. I expected to see my div but didn’t.

So, I added an else to my if (document.cookies == “” ) { } read the cookie in javascript and sure enough there is my test cookie.

I went into Tools -> Internnet Options -> Privacy tab -> and moved the slider all the way to the top, ‘Block All Cookies’. In the privacy tab, I clicked the ‘Advanced’ button and set for both first party cookies and third party cookies to prompt. I’m thinking that it should be blocked.

For example, as a test, I go to google.com in ie7, it alerts me if I want to allow or block two cookies from google.

Is there anything special I need to be doing to check for cookies disabled in ie7?

I have created a cookies.js file, for creating, reading, and deleting

function createCookie(name, value, days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toGMTString();
     }

     document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {

    //  we're going to search for the name of the cookie, followed by an =. So create this new string and put it in nameEQ
    var nameEQ = name + "=";

    //  split document.cookie on the semicolons. ca becomes an array containing all cookies that are set for this domain and path.
    var ca = document.cookie.split(';');

    for (var i = 0; i < ca.length; i++) {

        //  set c to the cookie to be checked.
        var c = ca[i];

        //  if the first character is a space, remove it by using the 'substring()' method. continue doing this until the first character is not a space.
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);

        //  now string c begins with the name of the current cookie. if this is the name of the desired cookie, we've found what we are looking for.
        //  we now only need to return the value of the cookie, which is the part of c that comes after nameEQ. By 
        //  returning this value we also end the function: mission accomplished.
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);

    }

    //  if after having gone through all cookies, we haven't found the name we are looking for, the cookie is not present, just return null.
    return null;

}

function eraseCookie(name) {
    createCookie(name, "", -1);
}

function cookiesEnabled() {
    if (document.cookies == "") {
       return false;
    }

    return true;
}

Just went ahead and downloaded jquery.cookie.js and in my function for checking if cookies eanbled, I have this:

function cookiesEnabled() {
    var TEST_COOKIE = 'test_cookie';
    $.cookie(TEST_COOKIE, true);
    if ($.cookie(TEST_COOKIE)) {
        $.cookie(TEST_COOKIE, null);
        return true;
    }
    return false;
}

this is working in chrome and firefox, but not in ie7.

i also tried this:

function cookiesEnabled() {
    var cookieEnabled = (navigator.cookieEnabled) ? true : false;

    if (typeof navigator.cookieEnabled === "undefined" && !cookieEnabled) {
        document.cookie = "testcookie";
        cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false;
    }

    return cookieEnabled;
}

this did work. I think at one point or navigator.cookieEnabled was supported by ie, but it appears that chrome and firefox support it as well.

This thing is really starting to get on my nerves!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:37:07+00:00Added an answer on May 23, 2026 at 10:37 am

    Here is an old test I found.

    Does it still work for IE?

    For other browsers it needs a setCookie, getCookie and delCookie function which I also have if needed

    function isCookieEnabled() {
       if (document.all) return navigator.cookieEnabled;
       setCookie('testcookie',today.getTime());
       var tc = getCookie('testcookie');
       delCookie('testcookie');
       return (tc == today.getTime());
    }
    
    /* Cookie functions originally by Bill Dortsch */
    function setCookie (name,value,expires,path,theDomain,secure) { 
       value = escape(value);
       var theCookie = name + "=" + value + 
       ((expires)    ? "; expires=" + expires.toGMTString() : "") + 
       ((path)       ? "; path="    + path   : "") + 
       ((theDomain)  ? "; domain="  + theDomain : "") + 
       ((secure)     ? "; secure"            : ""); 
       document.cookie = theCookie;
    } 
    
    function getCookie(Name) { 
       var search = Name + "=" 
       if (document.cookie.length > 0) { // if there are any cookies 
          offset = document.cookie.indexOf(search) 
          if (offset != -1) { // if cookie exists 
             offset += search.length 
             // set index of beginning of value 
             end = document.cookie.indexOf(";", offset) 
             // set index of end of cookie value 
             if (end == -1) end = document.cookie.length 
             return unescape(document.cookie.substring(offset, end)) 
          } 
       } 
    } 
    function delCookie(name,path,domain) {
       if (getCookie(name)) document.cookie = name + "=" +
          ((path)   ? ";path="   + path   : "") +
          ((domain) ? ";domain=" + domain : "") +
          ";expires=Thu, 01-Jan-70 00:00:01 GMT";
    //   alert(name+' marked for deletion');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still new to git, so bear with me. I started adding a feature
I am thinking of adding a feature to my website that allows me to
I am doing some significant refactoring and feature-adding on a project, and have just
Context: I'm working on master adding a simple feature. After a few minutes I
I am adding a webpart to the webpart gallery as part of a feature
I am creating an application. I have to implement a bookmark feature, and adding
I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and
I need to add a search feature to a website. Not being adept at
I have a website page with a simple form with 5 email fields. When
I've been struggling for quite a while to get this feature working: I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.