Allowing persistent cookies

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.

Re: Allowing persistent cookies

Postby magreenblatt » Thu Feb 01, 2018 5:29 pm

How are you running the message loop? What are you doing to "exit the app immediately"?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Allowing persistent cookies

Postby callum » Thu Feb 01, 2018 10:07 pm

Standard Windows message loop and calling CefDoMessageLoopWork(); regularly.

I shutdown in the usual way - I just mean I don't wait around after setting the cookie - I set it then tell the app to close.

bool force_close = false;
mBrowser->GetHost()->CloseBrowser(force_close);

then when my CefLifeSpanHandler::OnBeforeClose() is called, I exit the message loop

before finally calling cleaning up variables and calling CefShutdown();
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Allowing persistent cookies

Postby magreenblatt » Thu Feb 01, 2018 10:54 pm

Do you call CefDoMessageLoopWork a number of times immediately before calling CefShutdown?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Allowing persistent cookies

Postby callum » Fri Feb 02, 2018 4:39 pm

I don't - once the CefLifeSpanHandler::OnBeforeClose() is triggered, I exit my message loop that is calling CefDoMesssageLoopWork().

Is that correct or should I be calling it a few times before I finally call CefShutdown() ?
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Allowing persistent cookies

Postby Czarek » Fri Feb 02, 2018 4:57 pm

If you're using CefDoMessageLoopWork or external message pump then you should call CefDoMessageLoopWork several times before shutdown. See example code from cefclient:

https://github.com/chromiumembedded/cef ... win.cc#L91

Related:
https://bitbucket.org/chromiumembedded/cef/issues/1805/
viewtopic.php?f=6&t=13994
viewtopic.php?f=6&t=14154
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Allowing persistent cookies

Postby callum » Fri Feb 02, 2018 5:25 pm

Got it and thank you.

That worked and cookies are now persisted even when I initiate an exit directly after the cookie is set.

Sadly, as seems to be the nature of software, I removed the code I just added to make sure it was broken before and that also worked as expected - cookies saved.

Now I know what you're supposed to do though I can find a better repro for the failure case and use the new code to fix it.

Thank you both.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Allowing persistent cookies

Postby Czarek » Sat Feb 03, 2018 4:57 am

I guess documentation in cef_app.h for CefDoMessageLoopWork could be enhanced with a mention of this behavior. PRs are welcome :)
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Previous

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 105 guests