0

I am using moment.js to set the expiration date of my cookie (expires variable). The code below works fine in Chrome but IE11 and Edge just will not set the expiry date on the cookie

var nowDate = new Date();
        var creationDate = moment(nowDate);
        var expiresDate = moment(nowDate).utc();
        expiresDate.add(exdays, "d");
        var expires = "expires=" + expiresDate.toDate();

Everything I have read talks about IE11 expectign UTC format but even though I UTC() the moment object, IE11 is still not setting an expiry date

Mike
  • 2,391
  • 6
  • 33
  • 72

1 Answers1

0

1) If you're using developer tools of IE, you wouldn't be able to see all the details about the cookie (I don't know why) but that doesn't mean that it doesn't exist. I used a tool called IECookiesView and it showed me all the details about the cookie.

2-3) After further research, I found out that my app isn't working properly because of the time difference. The server time settings is UTC +00:00 while the user's time setting is UTC +08:00. When I changed the time settings of the user and made it similar with the server's the app worked properly. For browsers like Chrome and Mozilla, they can handle it even if I don't make any changes with the time settings (don't know why), IE can't.

Here's the post that helped me understand the problem.

Ricardo Costa
  • 704
  • 6
  • 27