473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to pass a cookie to a new Httpwebrequest?

Hello,

I am writing a simple httpwebrequest bot for a client, but for some reason i can't succeed in passing a single cookie.
I'll clarify in steps:
  1. Bot connects and gets cookie
  2. Bot tells the server its active
  3. Bot posts data to server
  4. Bots tells server its disconnecting
  5. Bot disconnects and quits

As far as i am now, i have the bot connecting and receiving the cookie, but its not passing it on to the next httpwebrequest.
The code:
Expand|Select|Wrap|Line Numbers
  1.  Dim postStart As HttpWebRequest
  2.         postStart = DirectCast(WebRequest.Create(startURL), HttpWebRequest)
  3.         postStart.CookieContainer = tempcookies
  4.         postStart.Method = "GET"
  5.         postStart.ContentType = "application/x-www-form-urlencoded"
  6.         postStart.UserAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b4) Gecko/20100818 Firefox/4.0b4"
  7.  
  8.         Dim startresponse As HttpWebResponse
  9.         startresponse = DirectCast(postStart.GetResponse(), HttpWebResponse)
  10.         tempcookies.Add(startresponse.Cookies)
  11.  
  12.         Dim startreader As New StreamReader(startresponse.GetResponseStream())
  13.         Dim start As String
  14.         start = startreader.ReadToEnd
  15.  
  16.         If InStr(start, "Connecting") Then
  17.             TohlaWorker.ReportProgress(0, start)
  18.             GoTo verbinden
  19.         ElseIf InStr(start, "5") Then
  20.             TohlaWorker.ReportProgress(0, "Connected")
  21.             gesprekcookie = tempcookies
  22.  
  23.             Dim postStarttyping As HttpWebRequest
  24.             postStarttyping = DirectCast(WebRequest.Create(typeURL), HttpWebRequest)
  25.             postStarttyping.Method = "POST"
  26.             postStarttyping.ContentType = "application/x-www-form-urlencoded"
  27.             postStarttyping.CookieContainer = gesprekcookie
  28.             postStarttyping.UserAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b4) Gecko/20100818 Firefox/4.0b4"
  29.  
  30.  
  31.             Dim starttypingresponse As HttpWebResponse
  32.             starttypingresponse = DirectCast(postStarttyping.GetResponse(), HttpWebResponse)
  33.             Dim poststartreader As New StreamReader(starttypingresponse.GetResponseStream())
  34.             Dim reply As String
  35.             reply = poststartreader.ReadToEnd
  36.  
  37.             If InStr(reply, "1") Then
  38.                 TohlaWorker.ReportProgress(0, "Simulating typing..")
  39.             Else
  40.                 TohlaWorker.ReportProgress(0, "Error simulating typing, starting over")
  41.                 GoTo verbinden
  42.             End If
If i check cook.Value after the second step, its empty. I dont understand whats going on here, can anyone point me in the right direction?
Dec 12 '10 #1
0 1747

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Carl | last post by:
Hi, I want to pass the value of the cookie created in VB to ASP. This doesn't work. Any idea? Thanks Carl .... <script language=vbscript> document.cookie="mycookie" '...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
1
by: Bhupesh Saini | last post by:
I am trying to call a ASPX page using HttpWebRequest class and pass cookie information to it. My ASPX pages gets called just fine, however none of the request cookies are available to the ASPX page....
3
by: JezB | last post by:
I know I can use the querystring mechanism to pass simple parameters to a Page using Response.Redirect, but Im having problems getting this to work using Server.Transfer or Server.Execute - is this...
1
by: davvel | last post by:
It has been 6 days of re-writing the same code in different ways to try and avoid a getResponse Timeout which haunted me for much too long now. I am trying to do a very simple thing which is...
1
by: Martin | last post by:
I have a web page that displays records from a database. I want to allow the user to specify his own "page size" - that is, the number of records to be displayed on a given page. I have a place set...
1
by: khalid sohail | last post by:
hi everybody i want to pass the window size parameter to <asp:hyperlink> attribute Navige URL Property. tell me how to pass the parameter to it.....actually i want to open the new window on the...
3
by: hemashiki | last post by:
hi i cant pass a same variable to multiplepages... while passing variables in sessions it shows warning and it doesn't pass to multiple pages here the coding which i hve used Registration.php...
5
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, Is there an easier way to handle that? I used Javascript to handle this when our two domains are hosted on two different servers(on different networks) and our search engine marketing...
66
by: happyse27 | last post by:
Hi All, my html code is sno 1) and perl code is sno 2). a) I tried to print $filename and it cant print out the value, only blank was displayed, and the file could not be uploaded. And it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.