ScottHamper / Cookies

JavaScript Client-Side Cookie Manipulation Library
The Unlicense
1.77k stars 170 forks source link

Always get true on edge browser even i have disabls all cookie in browser #62

Closed divsbhalala closed 7 years ago

divsbhalala commented 8 years ago

Hello

I have used your library for detecting cookie is disabled or not. But i am always get true Below is the my sample code

<script src="./src/cookies.js"></script>   
<script>
    (function() {
       var testKey = 'cookies.js';
         var areEnabled = Cookies.set(testKey, 1).get(testKey) === '1';
         Cookies.expire(testKey);
         alert(areEnabled);
    })();
alessandro-fazzi commented 8 years ago

But...are you disabling cookies in browser's settings?

divsbhalala commented 8 years ago

yes i have disable all cookie in EDGE browser. I have EDGE browser v11.0

ScottHamper commented 8 years ago

Hey @divsbhalala ,

I don't have Windows 10 at home, so I haven't been able to spend much time on Edge to investigate this issue.

However, I did a quick test at work today and ran into the same result as you. I loaded the Cookies.js unit test HTML page in Edge, and then blocked all cookies in Edge's settings menu. After restarting Edge, refreshing the page, and even clearing cache/cookies, the unit tests page still loads up with all tests passing (though it should be failing at this point, because I've disabled cookies!)

This seems really crazy to me. I'm not sure what's going on, but ultimately this doesn't appear to be an issue with Cookies.js itself - Edge appears to be legitimately still allowing cookies, despite the setting to block them. Cookies.js isn't doing anything fancy to subvert the browser (it's just a friendly wrapper around the native document.cookies JS API).

Either we're both doing something wrong, or Edge is. I think we'll need further investigation to determine which one it is.

ScottHamper commented 8 years ago

Hey @divsbhalala ,

When you ran into this issue, were you navigating to a page running on localhost?

I've discovered that Edge appears to properly block cookies for all sites other than localhost. I can even browse to 127.1.1.1 and cookies will be blocked. For whatever reason, it's just localhost that's an exception. I haven't found any documentation regarding this "feature", but there you have it.

Wtf, Microsoft?

ScottHamper commented 7 years ago

Closing due to inactivity, and because this seems like an issue with how Microsoft Edge handles cookies (not an issue with Cookies.js specifically).