Add Secure and SameSite=Lax flags to all cookie operations
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,14 +19,14 @@ export function setCookie(name, value, days=1) {
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
expires = "; expires=" + date.toUTCString();
|
||||
}
|
||||
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
||||
document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=Lax";
|
||||
}
|
||||
|
||||
export function setCookieWithoutExpiration(name, value) {
|
||||
document.cookie = name + "=" + (value || "");
|
||||
document.cookie = name + "=" + (value || "") + "; Secure; SameSite=Lax";
|
||||
}
|
||||
|
||||
export function deleteCookie(name, path = '/') {
|
||||
document.cookie = name + '=; Max-Age=-99999999; path=' + path;
|
||||
document.cookie = name + '=; Max-Age=-99999999; path=' + path + '; Secure; SameSite=Lax';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user