Assuming I am not running server side scripting of any kind, how can I set
and get
a cookie from within VBA code?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I saw a posting about this that might help for 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 strips out cookies for security reasons.
Hope that might get you started!