|
-
Mar 29th, 2010, 11:54 PM
#1
Thread Starter
Fanatic Member
Webrequest + Cookies...
So i've been reading all the posts, and even on msdn about cookies with webrequest.
I see the cookie, but how do i use it?
Scenario: I am logging into a website, and it saved the cookie..but each time i tell it to navigate somewhere else..says im not logged in... this would be because of the cookie.
Can anyone give me a quick n easy example of how to implement the cookie?
-
Mar 30th, 2010, 01:24 AM
#2
Addicted Member
Re: Webrequest + Cookies...
Code:
Dim Cookies As New CookieContainer
Cookies.Add(New Cookie("testcookie", "testvalue"))
Dim request As HttpWebRequest = CType(WebRequest.Create("http://www.google.fi/"), HttpWebRequest)
request.CookieContainer = Cookies
-
Mar 30th, 2010, 02:03 AM
#3
Thread Starter
Fanatic Member
Re: Webrequest + Cookies...
ok, i got the dim cookies as cookiecontainer part.
wouldnt the cookies.add come from the website itself?
-
Mar 30th, 2010, 02:09 AM
#4
Addicted Member
Re: Webrequest + Cookies...
Nope. If you're using webrequests you need to do everything yourself that a browser would normally do. In this case you need to parse the cookies from the response you get, add them into your cookies, and when requesting again set your request.CookieContainer = cookies.
EDIT: I think the cookies are already parsed in the response you get, so this should be a fairly simple task.
Last edited by DramaQueen; Mar 30th, 2010 at 02:12 AM.
-
Mar 30th, 2010, 02:30 AM
#5
Thread Starter
Fanatic Member
Re: Webrequest + Cookies...
I was playing with some commands and saw we had the cookie saved...
as it showed up...just didnt know how to...reuse it.
-
Mar 30th, 2010, 02:43 AM
#6
Addicted Member
Re: Webrequest + Cookies...
 Originally Posted by TCarter
I was playing with some commands and saw we had the cookie saved...
as it showed up...just didnt know how to...reuse it.
Well did you get it figured out now? If so, mark the thread as resolved
-
Mar 30th, 2010, 12:52 PM
#7
Thread Starter
Fanatic Member
Re: Webrequest + Cookies...
havnt had time to play with it to be honest, but i will if this works.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|