Reputation: 574
I want to add a cookie to the browser's session for testing that particular page. I am able to do that in Chrome and Firefox, as there is an option to add a cookie manually in the Developer tools -> Application -> Cookies. But in IE there is no particular way to add a cookie. Is there any way I can do that in IE?. This is what I have tried so far. From suggestions from a few people, I tried to do the following.
1) Use javascript:document.cookie="NAME=VALUE"
in the page I want to add a cookie. When I refresh the page, I don't find the cookie anymore.
2) Also tried after the page loaded to do document.cookie="NAME=VALUE"
in the console.
Both of the solutions doesn't seem to work. Any help is appreciated.
Upvotes: 0
Views: 3270
Reputation: 7089
Just add it artificially with javascript declaration document.cookie = "";
Note: This snippet won't work on StackOverflow, because of jsfiddle sandbox mode.
document.cookie = "username=Test Subject";
document.getElementById('showcookies').addEventListener('click', function(){
alert("Cookies JSON:" + document.cookie);
});
<button id="showcookies">Show coowkies!</button>
Alternatively add it in your HTML using the <script></script>
tags.
Additionally, check if your version of IE browser has cookies enabled in it's properties.
Upvotes: 1