title: Send Cookie through WebBrowser in VB
body: <p>So I have sent close to two hours searching for an answer but nothing is working. I need to to send a few cookies through my webbrowser object but for some reason the cookies aren't being read by my PHP file:</p>
  
  <pre><code>&lt;?php die('Your username is '.$_COOKIE['user']); ?&gt;
  </code></pre>
  
  <p>And my VB code to send the cookies:</p>
  
  <pre><code>For i = 0 To 4
  uploadBoxes(i).Navigate("about:blank")
  uploadBoxes(i).Document.Cookie = "user=" &amp; username.Text
  uploadBoxes(i).Navigate("http://*****/uploader/app.php")
  Next i
  </code></pre>
  
  <p>Again, any help would be appreciated and yes, I do need to send it over the webbrowser object. I also have browsed through MSDN database and even that has shed little light on this problem. </p>
  
  <p><em><strong></em> ------------------------------------------ THE ANSWER -------------------------------------------------</strong></p>
  
  <p>So I took the InternetSetCookie method and came up with this code that worked on making the cookies:</p>
  
  <pre><code>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
  </code></pre>