Forum Discussion
Veeta
10 years agoVisitor
Here's my general flow for adding previously stored cookies to a new roUrlTransfer object:
This works for me after a little trial and error. I believe the key is to make sure the hostname lines up everywhere. If you are setting a cookie for an empty domain, it may ignore it or at least not return it when you ask for cookies from a different domain. Cookie domain matching is a security-sensitive subject. Another hint is that we know it's libcurl under the covers. Looking at curl's documentation on cookie management might give more insight.
' Getting some useful cookies
Function login(hostname As String)
http = CreateObject("roUrlTransfer")
http.SetUrl("http://" + hostname + "/...")
http.EnableCookies()
http.AsyncPostFromString(...)
'... wait for response
http.GetCookies(hostname, "/")
End Function
' Using those cookies later
Function usecookies(hostname As String)
http = CreateObject("roUrlTransfer")
http.SetUrl("http://" + hostname + "/...")
http.EnableCookies()
http.AddCookies(cookies)
http.AsyncGetToString()
...
End Function
This works for me after a little trial and error. I believe the key is to make sure the hostname lines up everywhere. If you are setting a cookie for an empty domain, it may ignore it or at least not return it when you ask for cookies from a different domain. Cookie domain matching is a security-sensitive subject. Another hint is that we know it's libcurl under the covers. Looking at curl's documentation on cookie management might give more insight.