fcd4499205449601a65c9caa4ff95348ceee9484
kent
  Sun Mar 8 14:49:03 2015 -0700
Making it work behind a firewall/VPN where there is effectively no domain.

diff --git src/hg/lib/cart.c src/hg/lib/cart.c
index c2bef94..7fece59 100644
--- src/hg/lib/cart.c
+++ src/hg/lib/cart.c
@@ -1457,49 +1457,56 @@
 clearDbContents(conn, "userDb", hguid);
 clearDbContents(conn, "sessionDb", hgsid);
 cartDefaultDisconnector(&conn);
 }
 
 void cartWriteCookie(struct cart *cart, char *cookieName)
 /* Write out HTTP Set-Cookie statement for cart. */
 {
 char *domain = cfgVal("central.domain");
 if (sameWord("HTTPHOST", domain))
     {
     // IE9 does not accept portnames in cookie domains
     char *hostWithPort = hHttpHost();
     struct netParsedUrl npu;
     netParseUrl(hostWithPort, &npu);
+    if (strchr(npu.host, '.') != NULL)	// Domains without a . don't seem to be kept
 	domain = cloneString(npu.host);
+    else
+        domain = NULL;
     }
 
 char userIdKey[256];
 cartDbSecureId(userIdKey, sizeof userIdKey, cart->userInfo);
 // Some users reported blank cookie values. Do we see that here?
 if (sameString(userIdKey,"")) // make sure we do not write any blank cookies.
     {
     // Be sure we do not lose this message.
     // Because the error happens so early we cannot trust that the warn and error handlers
     // are setup correctly and working.
     verbose(1, "unexpected error in cartWriteCookie: userId string is empty.");
     dumpStack( "unexpected error in cartWriteCookie: userId string is empty.");
     warn(      "unexpected error in cartWriteCookie: userId string is empty.");
     }
 else
     {
+    if (!isEmpty(domain))
 	printf("Set-Cookie: %s=%s; path=/; domain=%s; expires=%s\r\n",
 		cookieName, userIdKey, domain, cookieDate());
+    else
+	printf("Set-Cookie: %s=%s; path=/; expires=%s\r\n",
+		cookieName, userIdKey, cookieDate());
     }
 if (geoMirrorEnabled())
     {
     // This occurs after the user has manually choosen to go back to the original site; we store redirect value into a cookie so we 
     // can use it in subsequent hgGateway requests before loading the user's cart
     char *redirect = cgiOptionalString("redirect");
     if (redirect)
         {
         printf("Set-Cookie: redirect=%s; path=/; domain=%s; expires=%s\r\n", redirect, cgiServerName(), cookieDate());
         }
     }
 }
 
 struct cart *cartForSession(char *cookieName, char **exclude,
                             struct hash *oldVars)