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")("passw ord")
response.write sResult
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")("passw
response.write sResult
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskCodeExampleWritingCookie.asp
Look at doing what is in the above URL maybe ?
Look at doing what is in the above URL maybe ?
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
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.
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/
https://www.experts-exchange.com/Web/Web_Languages/ASP/
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 ("").
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.
password = Request.Form("txtPassword"
Response.Cookies("password
Response.Cookies("mycookie
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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é
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é
http://support.microsoft.com/kb/q196062/
Attaining the cookies in ASP :
http://www.netspade.com/articles/asp/cookies.xml