Simple Question about InternetGetCookie

For reading a cookie I found the following code on the internet:
   Dim strCookieText As String * 256
   Dim blnReturn As Boolean
   blnReturn = InternetGetCookie("http://xxxx/xxx.htm", _
                  "CookieName", strCookieText, 255)
   If Not blnReturn Then
     MsgBox "Get Cookie Operation Failed", vbCritical
   Else
     MsgBox strCookieText, vbInformation
   End If

I am trying to read a cookie which is written by an asp page (which happens to be our login page). I want to read the cookie by a Visual Basic app which is on the client site. What I fail to understand is what is the first parameter to the InternetGetCookie. How do I read the cookie by a VB app.
LVL 1
sachinkasAsked:
Who is Participating?
 
vinnyd79Connect With a Mentor Commented:
Maybe this example will help.

http://www.karenware.com/powertools/ptcookie.asp
0
 
rkot2000Commented:
full sample from microsoft :



HOWTO: Set and Get Cookies for a URL Using WinInet APIs (Q196062)
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q196062
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
sachinkasAuthor Commented:
Yeah I have tried that in fact thats the code I have put. My question is what to put in the first parameter. I have tried that code, but get an error.
0
 
vinnyd79Commented:
The first parameter is url name,followed by cookie name and cookie data.What error are you getting?
0
 
vinky_jCommented:
I think there must be error in reading from the source file.Did u given the proper path in this?
0
 
sachinkasAuthor Commented:
The question is what proper path I should give. This is going to be a VB app which is installed on the clients machine. The way it works is this:
User logs in through an ASP page which writes the cookies.
Now the VB app should read the cookies.
Now you guys tell me what url or proper path I should give.
0
 
vinnyd79Commented:
The url should be the same url that was written by your asp page.
0
 
sachinkasAuthor Commented:
The problem is this url is always going to be different. There are different ways a user can login. I know that it writes the cookies in the profiles folder with a name similar to: <nt userid>@<domain>[2].txt
For e.g. emp001@abc123[2].txt
where emp001=nt userid of the user
abc123= the domain name. e.g. abc123.com
So maybe one way I could do this is try to somehow read this file and then read the cookie information.
But this is going to be real long. Isn't there some way in which if I know the domain name (abc123), it will return me the required cookie information.

Does anybody know how the Wininet api searches the cookie information. How does it know that THIS cookie file is mapped to THIS url.
Thanx.
0
 
rkot2000Commented:
may be you can try this :

' If CookieName is omitted, returns all the cookies as
' as semicolon-delimited list of NAME=VALUE pairs

http://www.vb2themax.com/Item.asp?PageID=CodeBank&ID=262

0
 
sachinkasAuthor Commented:
Superb Vinnyd79
I think you deserve the points.
How did you get this link. Good!!!
0
 
sachinkasAuthor Commented:
Superb Vinnyd79
I think you deserve the points.
How did you get this link. Good!!!
0
 
sachinkasAuthor Commented:
Guys I am deleting this question. Thanx for ur time
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.