navigator.cookieEnabled not working in IE9 in localhost

喜欢而已 提交于 2019-12-08 09:50:30

问题


I am working with asp.net, and in my logon.aspx page I have the following code copied from a previous question/answer: is it possible to check if cookies are enabled with modernizr ?

function are_cookies_enabled() {
        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);
    }

But when I run my local server (the Visual Studio 2010 integrated one), the variable cookieEnabled is always false, but it is only happening in my localhost, when I tried the same code in jsfiddle it works perfectly. (the above code works for all the browsers except in IE9, in localhost) Any idea??


回答1:


Try

option 1: http://127.0.0.1 / instead of http://localhost:5130/ ie; just disabling cookie on your browser will only set internet settings

So give IP adress -> Start-> Run->Cmd->Type ipconfig then you will see your IP adresses shown below

option 2

http://IPADRESS/app/urpag.aspx

then check with below javascript

<script type="text/javascript">
    document.write("Cookies enabled: " + navigator.cookieEnabled);
</script>



回答2:


I managed to lock out my previously working IE9 so that if security zone is Local Intranet, it will report:

navigator.cookieEnabled == false

If I change the zone to Internet and protected mode on, the cookies are enabled. Before this happened, I did change the privacy settings. I have no idea how to get it back. Perhaps a re-install would help.



来源:https://stackoverflow.com/questions/9364279/navigator-cookieenabled-not-working-in-ie9-in-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!