--- mod_rewrite.c.orig	Wed Apr 14 14:15:33 2004
+++ mod_rewrite.c	Tue May 11 10:35:00 2004
@@ -4333,6 +4333,12 @@
     }
 }
 
+static void expand_nullval(char **p) {
+	if(*p == NULL) return;
+
+	if(strcmp(*p, "null") == 0) *p = NULL;
+}
+
 static void add_cookie(request_rec *r, char *s)
 {
     char *var;
@@ -4357,7 +4363,21 @@
             path = NULL;
         }
 
-        if (var && val && domain) {
+	expand_nullval(&domain);
+	expand_nullval(&expires);
+	expand_nullval(&path);
+
+	// Treat 0 or empty string in expires (ie: "::")  as session based expire (use -1 to expire a cookie immediately)
+	/*
+	if(expires && atol(expires) == 0) {
+	  if(path == NULL && !apr_isdigit(*expires)) {
+		path = expires;
+		expires = NULL;
+	  }
+	}
+	*/
+
+        if (var && val) {
             /* FIX: use cached time similar to how logging does it */
             request_rec *rmain = r;
             char *notename;
@@ -4372,7 +4392,7 @@
                 cookie = apr_pstrcat(rmain->pool,
                                      var, "=", val,
                                      "; path=", (path)? path : "/",
-                                     "; domain=", domain,
+                                     (domain)?"; domain=":NULL,(domain)?domain:NULL,
                                      (expires)? "; expires=" : NULL,
                                      (expires)?
                                      ap_ht_time(r->pool,
