![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Demonstrates how to Get Cookies Sent by the HTTP ServerThis example demonstrates how to get the cookies that have been received from the HTTP server.
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp String sHtml String sXmlStr // This example assumes the Chilkat HTTP API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // When the HTTP object's SaveCookies property is enabled, cookies received from the // server are saved either to the directory specified by CookieDir (where they are stored as XML files) // or in memory if "memory" is specified. Set ComSaveCookies Of hoHttp To True Set ComCookieDir Of hoHttp To "memory" // Do a few GET's Get ComQuickGetStr Of hoHttp "https://google.com/" To sHtml Get ComQuickGetStr Of hoHttp "https://stripe.com/" To sHtml // Examine the cookies received from each domain. Get ComGetCookieXml Of hoHttp "google.com" To sXmlStr Showln sXmlStr // Sample output: // <?xml version="1.0" encoding="utf-8"?> // <cookies> // <cookie key=".google.com,/,AEC" v="0" expire="Tue, 17-Feb-2026 11:32:20 GMT" secure="yes"> // <AEC>AVh_......</AEC> // </cookie> // <cookie key=".google.com,/,NID" v="0" expire="Fri, 20-Feb-2026 11:32:20 GMT"> // <NID>525=A57i.......</NID> // </cookie> // </cookies> Get ComGetCookieXml Of hoHttp "stripe.com" To sXmlStr Showln sXmlStr // Sample output: // <?xml version="1.0" encoding="utf-8"?> // <cookies> // <cookie key="stripe.com,/,cid" v="0" maxAge="7776000" secure="yes"> // <cid>eba2891e-89e4-4aec-b9cf-e799d5b4b230</cid> // </cookie> // </cookies> End_Procedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.