所以我發送了近兩個小時尋找答案,但沒有任何工作。我要通過我的web瀏覽器對象發送一個幾塊餅乾,但由於某些原因,Cookie不會被我的PHP文件中讀取:在VB中通過WebBrowser發送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
再次,任何幫助將不勝感激,是的,我需要通過網頁瀏覽器對象發送它。我也瀏覽了MSDN數據庫,甚至對這個問題也沒有多大的瞭解。
------------------------------------------ THE答案-------------------------------------------------
所以我把InternetSetCookie方法以及與此代碼上製作餅乾的工作上來:
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
感謝您的幫助傑里米,這是我一直在尋找對於。 – 2012-07-31 11:19:56