I've made my program login to a site, how can I make it store cookies?

Pete

New member
Joined
Aug 23, 2005
Messages
2
Programming Experience
Beginner
VB.NET:
Private Function web_post(ByVal host As String, ByVal uri As String, ByVal postdata As String) As String

Dim tcp As New System.Net.Sockets.TcpClient 

Dim netstream As System.Net.Sockets.NetworkStream

Try

tcp.Connect(host, 80)

Catch ex As Exception

Return ex.Message

End Try

 

Dim sendbytes As Byte(), request As String

request = "POST " & uri & " HTTP/1.0" & ControlChars.CrLf & _

"Host: " & host & ControlChars.CrLf & _

"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6" & ControlChars.CrLf & _

"Connection: Close" & ControlChars.CrLf & _

"Content-Type: application/x-www-form-urlencoded" & ControlChars.CrLf & _

"Content-Length: " & Len(postdata).ToString & ControlChars.CrLf & _

ControlChars.CrLf & _

postdata & ControlChars.CrLf

 

sendbytes = System.Text.Encoding.ASCII.GetBytes(request)

netstream = tcp.GetStream()

netstream.Write(sendbytes, 0, sendbytes.Length)

tcp.ReceiveBufferSize = 1048576

Dim recv(tcp.ReceiveBufferSize) As Byte

netstream.Read(recv, 0, CInt(tcp.ReceiveBufferSize))

Dim out As String

out = System.Text.Encoding.UTF8.GetString(recv)

Return out

End Function

Thats my POST code, how would I make it store cookies?
 
Back
Top