Hi!
Each time I reopen my app I have to re-login on a website. How do I save cookies?
Also is it possible to add/remove cookies programmatically?
Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Cookies - how to save/load cookies?
Re: Cookies - how to save/load cookies?
GlobalCEFApp.PersistSessionCookies := True;
Found it =)
Found it =)
- salvadordf
- Posts: 4620
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Cookies - how to save/load cookies?
Hi,
Most of the times you can fix that problem by setting the GlobalCEFApp.cache and GlobalCEFApp.cookies properties before the GlobalCEFApp.StartMainProcess call.
GlobalCEFApp.PersistSessionCookies has a different purpose.
This is what the CEF code comments say about that setting :
Most of the times you can fix that problem by setting the GlobalCEFApp.cache and GlobalCEFApp.cookies properties before the GlobalCEFApp.StartMainProcess call.
GlobalCEFApp.PersistSessionCookies has a different purpose.
This is what the CEF code comments say about that setting :
Code: Select all
///
// To persist session cookies (cookies without an expiry date or validity
// interval) by default when using the global cookie manager set this value to
// true (1). Session cookies are generally intended to be transient and most
// Web browsers do not persist them. A |cache_path| value must also be
// specified to enable this feature. Also configurable using the
// "persist-session-cookies" command-line switch. Can be overridden for
// individual CefRequestContext instances via the
// CefRequestContextSettings.persist_session_cookies value.
///
- salvadordf
- Posts: 4620
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Cookies - how to save/load cookies?
The easiest way is by calling TChromium.DeleteCookies.
You can also get an interface of the cookie manager and call CookieManager.DeleteCookies
And you can also use the CookieVisitor demo code and set deleteCookie to True in the CookieVisitorProc for every cookie you want to delete.
As far as I know, there's no way to clear the cache while the program is running.
More info here :
http://magpcss.org/ceforum/viewtopic.php?f=7&t=293
You can delete the contents of the cache directory before the GlobalCEFApp.StartMainProcess call or after the GlobalCEFApp.Free call.
Be careful and delete the directory in the main process only.