Delete cookies, how?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Delete cookies, how?

Postby FinitelyFailed » Fri Sep 25, 2015 5:54 am

Hi

I'm using CEF3 2171 and I want to be able to:
    1. Create a browser
    2. Load the browser with an URL.
    3. Kill that browser.
    4. Clear cookies.
    5. Create a new browser.
    6. Load the new browser with an URL.

I.e. I visit a webshop, add an item to my cart, the browser is then removed and a new one is created, loaded with the same URL, than the shopping cart should be empty. I have managed to do the above except to delete cookies, i.e. the item is still in the cart.

I create the browser:
Code: Select all
   
CefWindowInfo windowInfo;
CefBrowserSettings browserSettings;   
CefRefPtr<CefRequestContext> requestContext = CefRequestContext::CreateContext(new CEFRequestContextHandler);
return CreateBrowser(windowInfo, mHandler.get(), url, browserSettings, requestContext);


Code: Select all
CefRefPtr<CefCookieManager> CEFRequestContextHandler::GetCookieManager()
{
    return CefCookieManager::GetGlobalManager();
}


and I try to delete the cookies:
Code: Select all
CefCookieManager::GetGlobalManager()->DeleteCookies("", "");

If |url| is empty all cookies for all hosts and domains will be deleted.


What am I doing wrong?
FinitelyFailed
Techie
 
Posts: 27
Joined: Wed Sep 16, 2015 1:22 am

Re: Delete cookies, how?

Postby magreenblatt » Fri Sep 25, 2015 6:03 am

If you don't want to persist cookies then use a new in-memory cookie store for each browser instead (CefCookieManager::CreateManager).
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Delete cookies, how?

Postby FinitelyFailed » Fri Sep 25, 2015 6:41 am

If I do:
Code: Select all
CefRefPtr<CefCookieManager> CEFRequestContextHandler::GetCookieManager()
{
    return CefCookieManager::CreateManager("", false);
}


The program crashes (Unhandled exception at 0x00007FFDA88C99A7 (libcef.dll) in player.exe: 0xC0000005: Access violation reading location 0xFFFFFF77C80FA7FC.). I do not know how to debug it correctly. If run the debug dll it asks for a "debugger_win.cc" which I can't find anywhere. :/
FinitelyFailed
Techie
 
Posts: 27
Joined: Wed Sep 16, 2015 1:22 am

Re: Delete cookies, how?

Postby magreenblatt » Fri Sep 25, 2015 6:46 am

GetCookieManager() will be called multiple times, so you shouldn't create the instance in that method. I don't know what is causing your crash -- what stack trace does it show you? You might also want to try a current CEF version (2357 branch or newer).
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Delete cookies, how?

Postby FinitelyFailed » Fri Sep 25, 2015 7:11 am

The crash happen as I created a new Manager for every call. When I fixed that it worked nicely. :)

When I try to use the libcef debug dll and the debug symbols (libcef.dll.pdb) Visual Studio asks for a "debugger_win.cc" which I can't find. Where do I find "debugger_win.cc" ?

Without it (debug dll etc.) the stack just looks like this:
libcef.dll!00007ffda88c99a7() Unknown
libcef.dll!00007ffda9a2cd14() Unknown
libcef.dll!00007ffda9a31259() Unknown
libcef.dll!00007ffda9a4bba4() Unknown
libcef.dll!00007ffda9ec9431() Unknown
libcef.dll!00007ffda8930d75() Unknown
libcef.dll!00007ffda89004cf() Unknown
libcef.dll!00007ffda88ffb99() Unknown
libcef.dll!00007ffda8931a1b() Unknown
libcef.dll!00007ffda8931f5b() Unknown
libcef.dll!00007ffda891920a() Unknown
libcef.dll!00007ffda8900218() Unknown
libcef.dll!00007ffda9c3526e() Unknown
libcef.dll!00007ffda9c359ef() Unknown
libcef.dll!00007ffda89198d2() Unknown
libcef.dll!00007ffda88fdd69() Unknown

I would love to get a nice debug stack trace working ...
FinitelyFailed
Techie
 
Posts: 27
Joined: Wed Sep 16, 2015 1:22 am

Re: Delete cookies, how?

Postby magreenblatt » Fri Sep 25, 2015 7:15 am

FinitelyFailed wrote:When I try to use the libcef debug dll and the debug symbols (libcef.dll.pdb) Visual Studio asks for a "debugger_win.cc" which I can't find. Where do I find "debugger_win.cc" ?

You would need a local Chromium checkout. Even without the Chromium checkout it should still show you a symbolized stack trace in the output window. What happens if you hit cancel to the dialog asking for "debugger_win.cc"?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Delete cookies, how?

Postby FinitelyFailed » Fri Sep 25, 2015 7:24 am

Yeah, you are correct. I do get a stack trace, even when the dialog appears. :)

You sir, are a guru and a scholar, thanks.
FinitelyFailed
Techie
 
Posts: 27
Joined: Wed Sep 16, 2015 1:22 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 100 guests

cron