-- Login
local hdrs,msg,resp, URI
print("Try connection to "..URI)
-- Got the form fill details from the chrome developer console
local b,c,l,h = http.request(URI ,formencode({
go = "ok",
username = [[username]] ,
password = [[La8TZmMc]] ,
autolog = "X"
}))
if not b then
print("Error making connection: "..tostring(c))
return
end
hdrs,msg = cm.add(l,URI)
local ft = {}
print("Try the check login url with the cookie.")
URI = l.location
hdrs, msg = cm.getCookieHeader(URI)
if not hdrs then return nil,msg end
resp = {http.request{
url = "">
sink = ltn12.sink.table(ft),
headers = hdrs
}
}
print("Done with the http request.")
if not resp[1] then
return nil,resp[2]
end
So basically you create a new cookie manager (cm) and then after each request just pass the header table to the add function in the cookie manager and then in the next request get the header using getCookieHeader function of the cookie manager. This has worked for me in the past few occasions requiring cookie management for websites that require login.