igor_g
April 29, 2019, 2:41pm
1
I set Cookie with expiration date:
document.cookie = 'name=value;expires=' + d.toUTCString();
Code above works perfect by Firefox and Chrom, but not by MS Edge. By MS Edge expiration date not available. Could I fix it, or this is persistent Edge bug?
There are many dates that fail when it comes to cookies.
Please supply more details.
igor_g
April 30, 2019, 3:47am
5
This date of one year ahead - april 2020. I don’t think that is the problem.
Okay, and with what code are you calculating that one year ahead?
igor_g
April 30, 2019, 9:03am
7
var d = new Date();
d.setSeconds(d.getSeconds() + parseInt(_cookieHidden.getAttribute('data-expires')));
document.cookie = '{name}={value};expires={expires}'
.replace('{name}', _cookieHidden.getAttribute('data-name'))
.replace('{value}', value)
.replace('{expires}', d.toUTCString());
But as I just said, that works fine by all browsers except of Edge.
So now we have 4 more problems to find information about.
a mystery _cookieHidden element
an unknown data-expires attribute
an unknown data-name attribute
and an unstated value variable
Can you please supply a simplified example so that we can realistically help you with it?
1 Like
I suspect .getSeconds doesn’t do what you think it does…
Yes, it doesn’t give the number of seconds since the last epoch. It would be getTime / 1000 that gives that.
Instead, getSeconds just gives a number ranging from 0 to 59.
Though of course, that isnt actually the problem here.
A rather important question, though: What domain are you trying to run this on? A TLD? Edge is known to silently drop cookies for TLD’s.
igor_g
April 30, 2019, 10:59pm
12
I’ve checked d.toUTCString() and that was correct. .getSeconds gives the seconds 0…59, .setSeconds makes automatically correction if given seconds number > 59.
igor_g
April 30, 2019, 11:01pm
13
No that is not TLD and cookie wasn’t dropped. Just expires doesn’t work.
system
Closed
July 31, 2019, 6:01am
14
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.