gsr
12/20/2023, 7:04 PM<script>
document.getElementById("acceptButton").addEventListener("click", function() {
var now = new Date();
now.setMonth(now.getMonth() + 3); // Set expiration for 90 days from now
var cID = document.getElementById("acceptButton").getAttribute("data-ID");
document.cookie = "cookieAccepted_" + cID + "=true;path=/;secure";
document.getElementById("cookieAlert").style.display = "none";
});
</script>
i tried in cf too but its the same
<cfscript>
// Assuming you have assigned the ID to a ColdFusion variable named cID
var now = createObject("java", "java.util.Date").init();
now.setMonth(now.getMonth() + 3);
var cookieValue = "cookieAccepted_" & cID & "=true; expires=" & now.toUTCString() & "; path=/; secure";
cfcookie(name="cookieAccepted_#cID#", value="true", expires="#now.toUTCString()#");
</cfscript>
<script>
// Assuming you have set the appropriate ID for the cookie alert element
document.getElementById("cookieAlert").style.display = "none";
</script>
want this both to be true how it can doneMyka Forrest
12/20/2023, 7:58 PMA cookie with theattribute is only sent to the server with an encrypted request over the HTTPS protocol. It's never sent with unsecured HTTP (except on localhost), which means man-in-the-middle attackers can't access it easily. Insecure sites (withSecurein the URL) can't set cookies with thehttp:attributeSecure
Myka Forrest
12/20/2023, 7:59 PMgsr
12/20/2023, 8:42 PMgsr
12/20/2023, 8:43 PMgsr
12/20/2023, 8:43 PMMyka Forrest
12/20/2023, 8:44 PMcookieValue but don't use that variable when actually setting your cookie.Myka Forrest
12/20/2023, 8:47 PMgsr
12/20/2023, 9:46 PMbkbk
12/21/2023, 12:28 PMMyka Forrest
12/21/2023, 2:21 PMgsr
12/21/2023, 5:25 PM<cfscript>
nowDate = createObject("java", "java.util.Date").init();
nowDate.setMonth(nowDate.getMonth() + 3);
// Format the date to a string
DateFormat = createObject("java", "java.text.SimpleDateFormat");
UTCFormat = DateFormat.init("EEE, dd MMM yyyy HH:mm:ss 'GMT'", createObject("java", "java.util.Locale").init("US"));
UTCFormat.setTimeZone(createObject("java", "java.util.TimeZone").getTimeZone("UTC"));
nowDateString = UTCFormat.format(nowDate);
cookieValue = "cookieAccepted_" & cID & "=true; expires=" & nowDateString & "; path=/; httpOnly; secure";
cfcookie(name="cookieAccepted_#cID#", value="true", expires="#nowDateString#");
</cfscript>
<script>
// Assuming you have set the appropriate ID for the cookie alert element
document.getElementById("cookieAlert").style.display = "none";
</script>