Set/Get Web Cookies

这一生的挚爱 提交于 2019-12-24 06:37:18

问题


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!



来源:https://stackoverflow.com/questions/345485/set-get-web-cookies

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!