Dan
Dan

Reputation: 1447

Microsoft Edge Extension document.cookie silently fails do store

I have a chrome extension where i store a cookie within the document.cookie. This is then refetched every time the user opens the popover.

I have used the Microsoft Edge convertor tool, to convert the extension to support the edge browser. This all worked as expected.

However a cookie is never persisted, is this a limitation of the edge browser? or am i missing something?

I can set, and get the cookie straight after and it is never returned.

Copied below is the source for setting the cookie

var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));var expires = "expires="+ d.toUTCString();        
var path = "path='/'";
document.cookie = cname + "=" + (cvalue) + "; " + expires + "; path=/;";

Getting the cookie:

var ca = document.cookie.split(';');
for(var i = 0; i <ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') {
        c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
        return (c.substring(name.length,c.length));
    }
}

return ""; 

Upvotes: 0

Views: 2424

Answers (1)

Sascha Sander
Sascha Sander

Reputation: 11

IE / Edge silently dropps cookies in the follwing situations:

On Top Level Domains, e.g. "example.com" On Domain Names containing underscores, e.g. "my_sub.doma.in"

https://blogs.msdn.microsoft.com/ieinternals/2009/08/20/internet-explorer-cookie-internals-faq/

Upvotes: 1

Related Questions