![]() |
GetCookies Method Example - Printable Version +- Antwise community forums (https://forums.antwise.com) +-- Forum: Antview (https://forums.antwise.com/forumdisplay.php?fid=11) +--- Forum: Antview for Windows (https://forums.antwise.com/forumdisplay.php?fid=12) +--- Thread: GetCookies Method Example (/showthread.php?tid=218) |
GetCookies Method Example - grusak - 2025-04-03 Hello, We are using the AntView WebView2 ActiveX control in our PowerBuilder 2022 R3 application. We are trying to use the GetCookies Method to get a list of cookies on the user's profile. Can anyone provide some sample code of how to do this? We're getting stuck understanding how to access the OnGetCookieList EVENT that is fired when the GetCookies() Method is invoked. Appreciate any code, feedback or insight. Kind Regards, Greg RE: GetCookies Method Example - wila - 2025-04-03 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 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 RE: GetCookies Method Example - grusak - 2025-04-04 (2025-04-03, 22:21:25)wila Wrote: Hi Greg, 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 So 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 RE: GetCookies Method Example - wila - 2025-04-04 Hi Greg, Ah yes, PowerBuilder and the handling of events that are not in the main part of the control, I'm slightly remembering some of it and the pain it incurred at the time. Just did a search and does the following link help? https://community.sap.com/t5/technology-q-a/code-in-ole-control-events-within-powerbuilder-not-executing/qaq-p/11497679 -- Wil RE: GetCookies Method Example - grusak - 2025-04-04 (2025-04-04, 08:51:09)wila Wrote: Hi Greg, Hello Wil, Unfortunately that doesn't help us. We are already inserting the AntView ActiveX .ocx control into a Window that exposes all of the main WebView2 Events that you have wrapped like onwebmessagereceived, onwindowclosedrequested, etc. Our trouble is with the OleObject Property of the OLE Control called CookieManager. In all my years of PowerBuilder Programming, I've never had to deal with an OleObject Property type, whereas other simple datatypes like string, boolean and numeric are straight forward. Any suggestions? Thanks again for all the response. Kind Regards, Greg ![]() RE: GetCookies Method Example - wila - 2025-04-04 Hi Greg, It's not very uncommon for an ActiveX control to expose access to its inner interfaces that way. We're just following the WebView2 design here. As you can see that bit is only 2 lines of code in VB6. Code: Public WithEvents CookieManager As AntviewAx2.AntViewCookieManager First creation of the object and then assigning it, so that the object is actually using the CookieManager interface from the instantiated browser object. When I look at PowerBuilder syntax then it should be something along the lines of: Code: int i Which is ... completely untested. You might not be able to assign the dispatch pointer or have to assign it in a specific way. I know that PowerBuilder can handle dispatch pointers as we're using those in the examples for PowerBuilder with the BrowserDispatch method. But they might not have a mechanism to assign an object to an existing interface (which would be weird IMO) For the document interface we made this: Code: int i Even once we get past this, there might still be issues with raising the events. However I do notice that you have an active developer subscription. Let's take the discussion on this to email and see if we can get you a solution for this issue. -- Wil |