Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetCookies Method Example
#2
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
Reply


Messages In This Thread
GetCookies Method Example - by grusak - 2025-04-03, 20:58:08
RE: GetCookies Method Example - by wila - 2025-04-03, 22:21:25
RE: GetCookies Method Example - by grusak - 2025-04-04, 01:05:03
RE: GetCookies Method Example - by wila - 2025-04-04, 08:51:09
RE: GetCookies Method Example - by grusak - 2025-04-04, 15:56:11
RE: GetCookies Method Example - by wila - 2025-04-04, 20:30:44
RE: GetCookies Method Example - by wila - 2025-10-15, 14:40:10
RE: GetCookies Method Example - by wila - 2025-11-05, 23:06:00

Forum Jump:


Users browsing this thread: 1 Guest(s)