Problem in reading internet explorer cookies using httprequest

I am trying to read the cookies previously created by the Internet explorer when the user open the domain 1, and I have created a function using the httpwebrequest  to read the cookies while calling the function from the other domain

but I can only see the cookies which are created on the run time when I call the website through the httprequest but the old existing cookies are not seen

I am looking for the answer for long time I hope someone can help me on this issues
I will appreciate any code examples
Thanks
'READ THE VALUE OF THE COOKIES FROM THE GIVEN DOMAIN
    Public Function getValue(ByVal strCookieKey As String, ByVal strCookieIndex As String, ByVal strDomain As String) As String
 
        Dim request As HttpWebRequest = CType(WebRequest.Create("http://" & strDomain), HttpWebRequest)
 
        'IF YOU WANT TO USE DEFAULT SETTINGS OF IE
        request.Proxy = WebProxy.GetDefaultProxy()
 
        request.Timeout = -1
        request.KeepAlive = True
 
        request.CookieContainer = New CookieContainer()
 
        Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
 
        'PRINT THE PROPERTIES OF EACH COOKIE.
        Dim cook As Cookie
        Dim strArr(10) As String
 
        For Each cook In response.Cookies
 
            If cook.Name = "WiggleBasket" Then
                strArr = Split(cook.ToString(), "=")
 
                If UCase(Trim(strArr(1))) = "BASKETID" Then
                    Return Server.HtmlEncode(Trim(strArr(2)))
                End If
 
            End If
 
        Next cook
 
        response.Close()
 
        Return ""
 
    End Function

Open in new window

LVL 1
shieldguyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WaldenLCommented:
If I understand your requirement, you're running code on a server in one domain, say www.mycompany.com and you want to access the cookies that IE has for another domain, say www.yourcompany.com. Simple answer, it can not be done! Cookies are scoped to the domain that created them, no browser will send them to another domain, it would be a huge security hole.

The best you can do is share cookies between subdomains in a single parent domain. For example, you can set a cookie on the forums.mycompany.com site, and read it on the support.mycompany.com site, but I don't think that's what you're looking to do.

From you code example you're creating a virtual browser on the server at mycompany.com and pointing it to the server at yourcompany.com, and that will work. But that connection it totally disconnected from the IE browser on your clients PC, so you won't have access to his cookies.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shieldguyAuthor Commented:
I agree with you and after all my research I came to the point thats its really cant be done
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.