所以我已经发送了将近两个小时来寻找答案,但没有任何效果。我需要通过我的 webbrowser 对象发送一些 cookie,但由于某种原因,我的 PHP 文件没有读取这些 cookie:
<?php die('Your username is '.$_COOKIE['user']); ?>
我的 VB 代码发送 cookie:
For i = 0 To 4
uploadBoxes(i).Navigate("about:blank")
uploadBoxes(i).Document.Cookie = "user=" & username.Text
uploadBoxes(i).Navigate("http://*****/uploader/app.php")
Next i
同样,任何帮助将不胜感激,是的,我确实需要通过 webbrowser 对象发送它。我还浏览了 MSDN 数据库,甚至对这个问题也没有多少启发。
- - - - - - - - - - - - - - - - - - - - - 答案 - - - ------------------------------------------
因此,我采用了 InternetSetCookie 方法,并提出了用于制作 cookie 的代码:
Imports System.Runtime.InteropServices
' No more data is available.
Const ERROR_NO_MORE_ITEMS = 259
' The data area passed to a system call is too small.
Const ERROR_INSUFFICIENT_BUFFER = 122
Private Declare Function InternetSetCookie Lib "wininet.dll" _
Alias "InternetSetCookieA" _
(ByVal lpszUrlName As String, _
ByVal lpszCookieName As String, _
ByVal lpszCookieData As String) As Boolean
Private sub something()
Dim bRet As Boolean
bRet = InternetSetCookie("http://*****/uploader/app.php", _
"user", "admin")
If bRet = False Then
MsgBox("Failed")
End If
uploadBoxes(i).Navigate("http:/*****/uploader/app.php")
End sub