C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to access Cookies from web pages


Posted Date: 22 Feb 2007    Resource Type: Code Snippets    Category: Web Access

Posted By: ANITA MARY JOSEPH       Member Level: Gold
Rating:     Points: 10



Cookies contain information that is stored by a browser. This snippet helps retreive the cookie information of an external website. (If you want to access Cookie values from the same webpage, then you must use Response.Cookies. This example is to retrieve Cookies from external sites)


Public Sub DisplayCookies()

'Create a WebRequest to the specified URI.
Dim req As HttpWebRequest = CType(WebRequest.Create("http://werweb.com/whoison.php"), HttpWebRequest)

'Get an empty cookie container.
req.CookieContainer = New CookieContainer

'Send the request and return the response.
Dim resp As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)

'Display the cookies.
Dim alertStr As String
alertStr = "Number of Cookies: " & resp.Cookies.Count.ToString() & Environment.NewLine()
alertStr = alertStr & "------------------------------" & Environment.NewLine()

Dim i As Integer
For i = 0 To resp.Cookies.Count - 1
alertStr = alertStr & resp.Cookies(i).Name & "=" & resp.Cookies(i).Value & Environment.NewLine()
Next
MessageBox.Show(alertStr)

'Close the Response.
resp.Close()
End Sub




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Retrieve web pages programmatically using WebResponse object
Previous Resource: Download and save a web page
Return to Discussion Resource Index
Post New Resource
Category: Web Access


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

fax server

Contact Us    Privacy Policy    Terms Of Use