Set / get web cookies

Assuming I am not using server side scripting of any type, how can I set

and get

cookie from VBA code?

+1


source to share


1 answer


I saw a post about this that might help in setting the cookie:

link text

Here is his code snippet:



Sub test()
Dim w As New WinHttp.WinHttpRequest
Dim t As String, qs As String
qs = "this=that&more=less"
w.Open "POST", "http://www.comparity.net/perl/form.pl?a=b", False
w.setRequestHeader "Cookie", "one=foo"
w.setRequestHeader "Cookie", "two=bar"
w.send qs
t = w.responseText
WriteTextFile "c:\test.html", t
Debug.Print w.Status
Debug.Print t
End Sub

      

Not sure about getting the cookie - one of the main posters mentions that XmlHttp removes cookies for security reasons.

Hope you can get started!

+2


source







All Articles