Update Cleanup "setCookie" function notes options: secure, httpOnly, Samesite

This commit is contained in:
Cody 2024-10-05 13:57:36 -07:00 committed by GitHub
parent dd0f8f4772
commit b5ea0dfbc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,19 +6,12 @@ Oqtane.Interop = {
d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
var cookieString = name + "=" + value + ";" + expires + ";path=/";
// Add SameSite attribute
if (sameSite === "Lax" || sameSite === "Strict" || sameSite === "None") {
cookieString += `; SameSite=${sameSite}`;
}
// Add Secure attribute
if (secure) {
cookieString += "; Secure";
}
// Note: HttpOnly cannot be set here; it needs to be handled server-side.
document.cookie = cookieString;
},
getCookie: function (name) {