Please check the following example for Web HTTP protocol:
You will need something like this to extract cookie value:
// Set-Cookie: session=bb415f62-eb9e-42fa-aedf-ca1887548216; path=/
web_reg_save_param_ex(
"ParamName=session",
"LB=session=",
"RB=;",
"Ordinal=all",
"Notfound=warning",
SEARCH_FILTERS,
"Scope=Cookies",
LAST);
then use it like this:
web_add_header("token", "{session}");
Here is a runnable example:
//Extract the uuid and save it under "session" parameter
web_reg_save_param_ex(
"ParamName=session",
"LB=\"uuid\": \"",
"RB=\"",
"Ordinal=all",
"Notfound=warning",
SEARCH_FILTERS,
"Scope=Body",
LAST);
web_url("get data",
"URL=http://httpbin.org/uuid",
"Snapshot=t1.inf",
LAST);
if (atoi(lr_eval_string("{session_count}"))>0) lr_save_string(lr_eval_string("{session_1}"),"token");
web_add_header("token", "{token}");
web_reg_save_param_ex(
"ParamName=session",
"LB=\"uuid\": \"",
"RB=\"",
"Ordinal=all",
"Notfound=warning",
SEARCH_FILTERS,
"Scope=Body",
LAST);
web_url("get data_2",
"URL=http://httpbin.org/uuid",
"Snapshot=t2.inf",
LAST);
//If there is a new session, overwrite the token parameter
if (atoi(lr_eval_string("{session_count}"))>0) lr_save_string(lr_eval_string("{session_1}"),"token");
web_add_header("token", "{token}");
web_reg_save_param_ex(
"ParamName=session",
"LB=\"uuid\": \"",
"RB=\"",
"Ordinal=all",
"Notfound=warning",
SEARCH_FILTERS,
"Scope=Body",
LAST);
web_url("get data_3",
"URL=http://httpbin.org/uuid",
"Snapshot=t3.inf",
LAST);