Omar J. Omar J. - 4 months ago 17x Question

Send Cookie through WebBrowser in VB

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:

<?php die('Your username is '.$_COOKIE['user']); ?>

And my VB code to send the cookies:

For i = 0 To 4
uploadBoxes(i).Document.Cookie = "user=" & username.Text
Next i

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.

------------------------------------------ THE ANSWER -------------------------------------------------

So I took the InternetSetCookie method and came up with this code that worked on making the cookies:

Imports System.Runtime.InteropServices

' No more data is available.

' The data area passed to a system call is too small.

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
End If
End sub


  <DllImport("wininet.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
      Public Shared Function InternetSetCookie(lpszUrl As String, _
      lpszCookieName As String, lpszCookieDataAs String) As Boolean
     End Function

Imports System.Runtime.InteropServices
Sub InternetSetCookiePseudoCode()
'`CookieCollection` was populated using HttpWebRequest/Response calls
Dim i As Integer = 0
InternetSetCookie("", Nothing, CookieCollection(i).ToString() & "; expires = Sun, 01-Jul-2014 00:00:00 GMT")
'repeat for however many cookies you've got

browser.Navigate("", True)
End Sub