2025-04-04, 01:05:03
(2025-04-03, 22:21:25)wila Wrote: Hi Greg,
I don't have PowerBuilder installed at this moment, but in VB6 the code to get cookies for a current URL looks like this (this is using AntView version 2.x code, so slight changes will be needed for AntView version 1.x - anything AntviewAx2 then should be AntviewAx )
Code:Option Explicit Public WithEvents CookieManager As AntviewAx2.AntViewCookieManager ' Private Sub CookieButton_Click() ' click Set CookieManager = EdgeWebBrowser.CookieManager CookieManager.GetCookies EdgeWebBrowser.Source End Sub Private Sub CookieManager_OnGetCookieList(ByVal HResult As Long, ByVal Args As AntviewAx2.IAntViewCookieList) Dim ndx As Integer Dim Cookie As AntviewAx2.AntViewCookie If HResult = 0 Then If Args.Count > 0 Then For ndx = 0 To (Args.Count - 1) Set Cookie = Args.ValueAtIndex(ndx) If (Cookie.Name <> "") Then MsgBox "name " & Cookie.Name & " = " & Cookie.Value, vbOKOnly, "Cookie " & CStr(ndx + 1) & " of " & CStr(Args.Count) End If Next Else MsgBox "No Cookies have been set for this site.", vbOKOnly, "Cookies" End If End If End Sub
So in summary, you have to first create an object based on the AntViewCookiemanager interface.
Once you want to use that, assign the WebBrowser object IDispatch pointer of the cookiemanager to your object and invoke the GetCookies method with the URL from the currently browsed page.
The OnGetCookieList event from the Cookiemanager object is where you can enumerate the cookies.
The Args parameter contains a AntViewCookieList object that has a list with all the cookies.
Hope this helps,
--
Wil
Unfortunately, that is the problem we're seeing. In PowerBuilder, we don't have access to the OnGetCookieList event since we are just getting a handle to the CookieManager object as follows:
Code:
oleobject lole_cookies
String ls_cookies, ls_uri
lole_cookies = ole_webview2.Object.CookieManager
IF IsValid(lole_cookies) THEN
lole_cookies.GetCookies(ls_uri)
END IFSo we can issue the GetCookies() Method call, but don't see a way of writing any code in the OnGetCookieList event to get the cokkies.
If you could provide a PowerBuilder example to show what we are missing, that would be greatly appreciated.
Regards,
Greg

