|
@@ -182,8 +182,22 @@ class Web {
|
|
/**
|
|
/**
|
|
Set a Cookie value in the HTTP headers. Same remark as setHeader.
|
|
Set a Cookie value in the HTTP headers. Same remark as setHeader.
|
|
**/
|
|
**/
|
|
- public static function setCookie( k : String, v : String ) {
|
|
|
|
- _set_cookie(untyped k.__s,untyped v.__s);
|
|
|
|
|
|
+ public static function setCookie( key : String, value : String, ?expire: Date, ?domain: String, ?path: String, ?secure: Bool ) {
|
|
|
|
+ var buf = new StringBuf();
|
|
|
|
+ buf.add(value);
|
|
|
|
+ addPair(buf, "expires=", DateTools.format(expire, "%a, %d-%b-%Y %H:%M:%S GMT"));
|
|
|
|
+ addPair(buf, "domain=", domain);
|
|
|
|
+ addPair(buf, "path=", path);
|
|
|
|
+ if( secure ) addPair(buf, "secure", "");
|
|
|
|
+ var v = buf.toString();
|
|
|
|
+ _set_cookie(untyped key.__s, untyped v.__s);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static function addPair( buf : StringBuf, name, value ) {
|
|
|
|
+ if( value == null ) return;
|
|
|
|
+ buf.add("; ");
|
|
|
|
+ buf.add(name);
|
|
|
|
+ buf.add(value);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|