I am trying to set SameSite attribute using javascript on my site . The code is
<script type="text/javascript">
document.cookie = "AC-C=ac-c;expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;HttpOnly;SameSite=Lax";
</script>
The cookie is being set but the SameSite attribute is not being set. Any idea where am I missing?
Thanks
Your problem is not with SameSite
, but with HttpOnly
. HttpOnly
and SameSite
are 2 independent things, if you remove HttpOnly
it will be working… and cookie will be set with SameSite
.
<script>
document.cookie = "AC-C=ac-c;expires=Fri, 31 Dec 9999 23:59:59 GMT;path=/;SameSite=Lax";
alert( document.cookie );
</script>