MEDIUM: stats: report the cookie value in the server & backend CSV dumps

The server's cookie value is now reported in the "cookie" column and
used as-is from the HTML dump. It was the last reference to the sv
pointer from this place.

The same was done for the backend's dump.
diff --git a/doc/management.txt b/doc/management.txt
index 5ff45c0..9c07151 100644
--- a/doc/management.txt
+++ b/doc/management.txt
@@ -1023,6 +1023,7 @@
  71. agent_fall [...S]: agent's "fall" parameter, normally 1
  72. agent_health [...S]: agent's health parameter, between 0 and rise+fall-1
  73. addr [...S]: server's address:port. IPv6 has brackets around the address.
+ 74: cookie [..BS]: server's cookie value or backend's cookie name
 
 
 9.2. Unix Socket commands
diff --git a/src/dumpstats.c b/src/dumpstats.c
index b6145a7..411f05e 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -334,6 +334,7 @@
 	ST_F_AGENT_FALL,
 	ST_F_AGENT_HEALTH,
 	ST_F_ADDR,
+	ST_F_COOKIE,
 
 	/* must always be the last one */
 	ST_F_TOTAL_FIELDS
@@ -418,6 +419,7 @@
 	[ST_F_AGENT_FALL]     = "agent_fall",
 	[ST_F_AGENT_HEALTH]   = "agent_health",
 	[ST_F_ADDR]           = "addr",
+	[ST_F_COOKIE]         = "cookie",
 };
 
 /* one line of stats */
@@ -3841,6 +3843,9 @@
 		default: /* address family not supported */
 			break;
 		}
+
+		if (sv->cookie)
+			stats[ST_F_COOKIE] = mkf_str(FO_CONFIG|FN_NAME|FS_SERVICE, sv->cookie);
 	}
 
 	if (appctx->ctx.stats.flags & STAT_FMT_HTML) {
@@ -3878,12 +3883,10 @@
 			chunk_appendf(&trash, "id: %d", stats[ST_F_SID].u.u32);
 
 			/* cookie */
-			if (sv->cookie) {
+			if (stats[ST_F_COOKIE].type) {
 				chunk_appendf(&trash, ", cookie: '");
-
-				chunk_initstr(&src, sv->cookie);
+				chunk_initstr(&src, field_str(stats, ST_F_COOKIE));
 				chunk_htmlencode(&trash, &src);
-
 				chunk_appendf(&trash, "'");
 			}
 
@@ -4139,6 +4142,10 @@
 	stats[ST_F_TYPE]     = mkf_u32(FO_CONFIG|FS_SERVICE, STATS_TYPE_BE);
 	stats[ST_F_RATE]     = mkf_u32(0, read_freq_ctr(&px->be_sess_per_sec));
 	stats[ST_F_RATE_MAX] = mkf_u32(0, px->be_counters.sps_max);
+	if (flags & ST_SHLGNDS) {
+		if (px->cookie_name)
+			stats[ST_F_COOKIE] = mkf_str(FO_CONFIG|FN_NAME|FS_SERVICE, px->cookie_name);
+	}
 
 	/* http response: 1xx, 2xx, 3xx, 4xx, 5xx, other */
 	if (px->mode == PR_MODE_HTTP) {
@@ -4187,9 +4194,9 @@
 			              backend_lb_algo_str(px->lbprm.algo & BE_LB_ALGO));
 
 			/* cookie */
-			if (px->cookie_name) {
+			if (stats[ST_F_COOKIE].type) {
 				chunk_appendf(&trash, ", cookie: '");
-				chunk_initstr(&src, px->cookie_name);
+				chunk_initstr(&src, field_str(stats, ST_F_COOKIE));
 				chunk_htmlencode(&trash, &src);
 				chunk_appendf(&trash, "'");
 			}