Link to home
Start Free TrialLog in
Avatar of 410328
410328

asked on

Creating Cookies in VB6 and reading in ASP

Hi, I'm trying to create coockies in VB6 and reading them in an ASP page, but I still get an empty result. Does someone has a clue for this?
With thanks in advance, A. Caljé


----- VB6 -----

      Option Explicit

      ' No more data is available.
      Const ERROR_NO_MORE_ITEMS = 259

      ' The data area passed to a system call is too small.
      Const ERROR_INSUFFICIENT_BUFFER = 122

      Private Declare Function InternetSetCookie Lib "wininet.dll" _
       Alias "InternetSetCookieA" _
       (ByVal lpszUrlName As String, _
       ByVal lpszCookieName As String, _
       ByVal lpszCookieData As String) As Boolean

      Private Sub Command1_Click()
       Dim bRet As Boolean
       bRet = InternetSetCookie("www.mysite.com", _
        "password", "123456")
       If bRet = False Then
           MsgBox "Failed"
       End If
      End Sub

----- ASP -----

Dim sResult
sResult = request.Cookies("www.mysite.com")("password")
response.write sResult
Avatar of Shane Russell
Shane Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

This site will show you how to create and read cookies in vb 6 :

http://support.microsoft.com/kb/q196062/

Attaining the cookies in ASP :

http://www.netspade.com/articles/asp/cookies.xml
Avatar of 410328
410328

ASKER

Hi Gecko, thanks for your suggestion. My examplecode in the question is the same as the microsoft link. The other asp-example is about reading and writing coockies in asp.

I do not have problems writing and reading in asp, nor writing and reading cookies in VB. But I have a problem writing in VB and reading the same cookie in ASP
so if you open the cookie you created the text you told it to write is in the cookie itself ? What about trying something simple just for test purposes, ie only write one value to the cookie and see if ASP will attain that cookies value, if so then at least we know it works, then from there try and read more then one value again.
410328

If the cookie is for "your site" then the asp code should read:
Dim sResult
sResult = request.Cookies("password")
response.write sResult

If the cookie is not for "your site", then why are you trying to read it?  It doesn't belong to you, and what you are trying to do is steal information from the users computer... which the mods at *this* site will frown on.
What about having a pointer question to this one from the ASP area of this site :

https://www.experts-exchange.com/Web/Web_Languages/ASP/
Avatar of 410328

ASKER

Hi PaulHews, Thanks for your reply,

I'm trying to achieve to write a cookie with my vb-program thats located in the IE-toolbar and to pass a password to MY asp-page on MY site. In this way a user can login at my site without entering his password all the time. So I do not understand why mentioning the subject in your last two lines of your reply.

Anyway: I tried to retrieve the information with your example, but also it returns nothing ("").
The correct way to do that would be to use ASP to write the cookie...  You could do that from the login script.

password = Request.Form("txtPassword")
Response.Cookies("password") = password
Response.Cookies("mycookie").Expires =  DateAdd("ww", 2, Date)  '2 weeks from today they will have to login again.

ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 410328

ASKER

Thanks PaulHews,

After your last messages I decided to use asp also to crete the cookie, because I could not make it possible to create with vb and read with asp the same cookie.

Before my program actually points IE to my site it first visits an asp-page that creates the cookie.

Thanks for all suggestions and replies and comments in this question.
With greetings, A. Caljé