Skip to content

Commit

Permalink
allows setting secure and sameSite attributes in js.Cookie (#10317)
Browse files Browse the repository at this point in the history
  • Loading branch information
poga committed Sep 9, 2021
1 parent 18ef6be commit 16891c2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion std/js/Cookie.hx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Cookie {
Create or update a cookie.
@param expireDelay In seconds. If null, the cookie expires at end of session.
**/
public static function set(name:String, value:String, ?expireDelay:Int, ?path:String, ?domain:String) {
public static function set(name:String, value:String, ?expireDelay:Int, ?path:String, ?domain:String, ?secure:Bool, ?sameSite:String) {
var s = name + "=" + StringTools.urlEncode(value);
if (expireDelay != null) {
var d = DateTools.delta(Date.now(), expireDelay * 1000);
Expand All @@ -41,6 +41,12 @@ class Cookie {
if (domain != null) {
s += ";domain=" + domain;
}
if (secure == true) {
s += ";secure";
}
if (sameSite != null) {
s += ";SameSite=" + sameSite;
}
Browser.document.cookie = s;
}

Expand Down

0 comments on commit 16891c2

Please sign in to comment.