Description of the issue:
On a static website the only way to set cookies is with JavaScript. It seems, when I want to create a ticket that should not expire in the near future (e.g.: 1 year) the browser sets it to only 7 days.
On my website I have this mandatory GDPR popup accept/decline state saved into cookie, but it keeps pop up every week.
Steps to Reproduce (add as many as necessary): 1. 2. 3.
Open the dev tools console on any website. Create a 1 year cookie with the following code:
let days = 365;
let date = new Date;
date.setTime(date.getTime() + 24 * days * 60 * 60 * 1e3);
document.cookie = 'test=xxxxx;expires='+date.toUTCString()+';path=/;SameSite=Lax;secure';
Actual Result (gifs and screenshots are welcome!):
The cookie expires 7 days from now: https://i.postimg.cc/BQZ0Bt7J/expire.png
Expected result:
The new cookie should expire 365 days from now.
Reproduces how often:
Every time.
Operating System and Brave Version(See the About Brave
page in the main menu):
- OS: macOS Catalina 10.15.2 (but experienced also on Windows 10)
- Brave: Version 1.2.43 Chromium: 79.0.3945.130 (Official Build) (64-bit)
Additional Information:
This issue happens only in Brave and Safari browsers. In Chrome, FF, Opera and Edge it works as expected.
There are more and more static websites on the market, and the GDPR Consent is mandatory within the European Union. These websites can only store such decision in cookies. But bothering users too often is not a good practice. Please provide a fix or a solution how to create long term, non-tracking cookies from JavaScript.