Index: std/neko/Web.hx
===================================================================
RCS file: /cvsroot/haxe/std/neko/Web.hx,v
retrieving revision 1.18
diff -u -r1.18 Web.hx
--- std/neko/Web.hx	12 Sep 2007 09:43:31 -0000	1.18
+++ std/neko/Web.hx	30 Nov 2007 13:03:40 -0000
@@ -178,12 +178,32 @@
 		return h;
 	}
 
+	static function addPair(buf: StringBuf, name: String, value: String) {
+		if (null != value) {
+			buf.add("; ");
+			buf.add(name);
+			buf.add(value);
+		}
+	}
 
 	/**
 		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( k : String, v : String, ?expire: Date, ?domain: String, ?path: String, ?secure: Bool ) {
+		if (null == expire && null == domain && null == path && null == secure) {
+			_set_cookie(untyped k.__s,untyped v.__s);
+		} else {
+			var buf = new StringBuf();
+			buf.add(v);
+			addPair(buf, "expires=", DateTools.format(expire, "%a, %d-%b-%Y %H:%M:%S GMT"));
+			addPair(buf, "domain=", domain);
+			addPair(buf, "path=", path);
+			if (true == secure) {
+				addPair(buf, "secure", "");
+			}
+			var res = buf.toString();
+			_set_cookie(untyped k.__s, untyped res.__s);
+		}
 	}
 
 	/**
