cookie based auth using fetch

I am trying to convert some python code to a Mikrotik script. The code captures the current antenna strength from an ubiquiti lightbeam. The python code uses a session to pass cookie based auth between two calls. Is there any way to use the fetch tool to do this?

Here is what I have so far which successfully authenticates. But, the cookie is not in the received payload.

/tool
{
    :local username myuser
    :local password mypass
    :local ip 1.1.1.1
    :local loginurl "https://$ip/api/auth"
    :local statusurl "http://$ip/status.cgi"

    fetch mode=https url=$loginurl http-method=post http-data="username=$username&password=$password"

    #insert next fetch command using retrieved cookie
}

actually if I pass output=user-with-headers I see the cookie info. Now I just need to parse out the cookie and pass it. Anyone done this before?

mikrotik script to fetch the current signal strength from an lbe or af60 using cookie based authentication

/tool
{
:local username
:local password
:local ip
:local loginurl "https://$ip/api/auth"
:local statusurl "https://$ip/status.cgi"
:local strData [fetch mode=https url=$loginurl http-method=post http-data="username=$username&password=$password" output=user-with-headers as-value ];
:local headerData ([:toarray $strData ]->"http-headers");
:local headerData ($strData->"http-headers");
:local cookieData [:pick $headerData 4]
:local cookie [:pick $cookieData ([:find $cookieData " "]+1) [:find $cookieData ";"]]
:local header "content-type: application/json,Cookie: $cookie; ok=1" ;
:put $header
:set strData [fetch mode=https url=$statusurl http-method=get http-header-field=$header output=user as-value ];
:set strData ($strData->"data");
:local startSignal [:pick $strData ([:find $strData ""signal":"]+9) [:len $strData]]
:local signalStrenght [:pick $startSignal 0 [:find $startSignal ","]]
:put "Current signal strength = $signalStrenght"
}

We are trying to do more or less the same thing as you, but we cannot get cookie-information from our authentication request:

http://forum.mikrotik.com/t/trouble-with-fetch-tool-and-cookie-handling/181924/1

Any ideas?