![]() |
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
(SQL Server) Example: Http.ClearInMemoryCookies methodDemonstrates how to call the ClearInMemoryCookies method. Note: This example requires Chilkat v11.1.0 or greater.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @http int EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- Save received cookies to an in-memory cache. EXEC sp_OASetProperty @http, 'CookieDir', 'memory' EXEC sp_OASetProperty @http, 'SaveCookies', 1 -- Indicate that saved cookies should be sent on subsequent requests (where the cookie's attributes match the request) EXEC sp_OASetProperty @http, 'SendCookies', 1 DECLARE @html nvarchar(4000) EXEC sp_OAMethod @http, 'QuickGetStr', @html OUT, 'https://www.paypal.com/' -- Examine the cookies cached for the domain paypal.com DECLARE @xmlStr nvarchar(4000) EXEC sp_OAMethod @http, 'GetCookieXml', @xmlStr OUT, 'paypal.com' PRINT @xmlStr -- Sample output: -- <?xml version="1.0" encoding="utf-8"?> -- <cookies> -- <cookie key="/,/,$x-enc" v="0" maxAge="1800"> -- <x-enc>URI_ENCODING</x-enc> -- </cookie> -- <cookie key=".paypal.com,/,LANG" v="0" expire="Fri, 15 Aug 2025 23:42:44 GMT" maxAge="31556000" secure="yes"> -- <LANG>en_US%3BUS</LANG> -- </cookie> -- <cookie key="paypal.com,/,ts" v="0" expire="Mon, 14 Aug 2028 14:56:50 GMT" secure="yes"> -- <ts>vreXpYrS%3D1848964208%26vteXpYrS%3D1755271608%26vr%3Dae3bc3371987669703182e1efffffffe%26vt%3Dae3bc337198369703182e1efffffffd%26vtyp%3Dnew</ts> -- </cookie> -- <cookie key="paypal.com,/,ts_c" v="0" expire="Mon, 14 Aug 2028 14:56:50 GMT" secure="yes"> -- <ts_c>vr%3Dae3bc3371987365703182e1efffffffe%26vt%3Dae3bc337198759703182e1efffffffd</ts_c> -- </cookie> -- </cookies> -- Clear the in-memory cookies. EXEC sp_OAMethod @http, 'ClearInMemoryCookies', NULL -- The cached cookies should not be present. EXEC sp_OAMethod @http, 'GetCookieXml', @xmlStr OUT, 'paypal.com' PRINT 'After calling ClearInMemoryCookies...' PRINT @xmlStr PRINT '----' EXEC @hr = sp_OADestroy @http END GO |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.