Hi,
I'm looking for a way to delete cookies WITHOUT having to exit my application.
To do so, i'm destroying the TChromium component and trying to delete the cookies dir. But still i receive an error telling my application is using the cookies dir. Any hints ?
Thanks !
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.
Delete cookies
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Delete cookies
Actually i've noticed when i run the code below :
chromium1.free;
Nothing happens, Chromium is still working.
Is there any right way to destroy the component ?
chromium1.free;
Nothing happens, Chromium is still working.
Is there any right way to destroy the component ?
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Delete cookies
Hi,
You can delete the cookies at runtime by calling TChromium.DeleteCookies.
The TChromium.OnCookiesDeleted event will notify you when they are deleted and how many were deleted.
If you need to select what cookies must be deleted while preserving other cookies then you will have to use a TCefFastCookieVisitor as shown in the CookieVisitor demo.
Read this for more information about the CookieVisitor :
https://magpcss.org/ceforum/apidocs3/pr ... sitor.html
CEF4Delphi uses a procedure that is executed when the "Visit" method is called. That procedure is called "CookieVisitorProc" In the CookieVisitor demo and it's specified when you create the TCefFastCookieVisitor instance.
You can delete the cookies at runtime by calling TChromium.DeleteCookies.
The TChromium.OnCookiesDeleted event will notify you when they are deleted and how many were deleted.
If you need to select what cookies must be deleted while preserving other cookies then you will have to use a TCefFastCookieVisitor as shown in the CookieVisitor demo.
Read this for more information about the CookieVisitor :
https://magpcss.org/ceforum/apidocs3/pr ... sitor.html
CEF4Delphi uses a procedure that is executed when the "Visit" method is called. That procedure is called "CookieVisitorProc" In the CookieVisitor demo and it's specified when you create the TCefFastCookieVisitor instance.
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Delete cookies
I tried use the .deletecookies method, but somehow my browser instance is still logged on the website i'm browsing, so i assume the cookies are not entirely deleted.
I can achieve the result i desire by closing my app and manually delete the entire cookies dir, and reopening the app.
But i'm trying a way to do this without close / open my app.
I can achieve the result i desire by closing my app and manually delete the entire cookies dir, and reopening the app.
But i'm trying a way to do this without close / open my app.
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Delete cookies
If i want to do exactly this (delete entire cookies dir), what should be the procedure ?
This is what i'm trying :
1 - Destroy/free TChromium
2 - Delete the cookies dir
3 - Create TChromium
Problem is, in the step 2 Windows says my app is currently using the cookies dir.
This is what i'm trying :
1 - Destroy/free TChromium
2 - Delete the cookies dir
3 - Create TChromium
Problem is, in the step 2 Windows says my app is currently using the cookies dir.
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Delete cookies
You can't delete the cache/cookies files manually while the application is running because CEF is using them.
If the session is still open after deleting the cookies it could mean that the website is using an alternative method to keep the session open without cookies. Search "maintain sessions without cookies" in Google for more information about this.
You can use CookieVisitor to see if there's any cookie left after the TChromium.DeleteCookies procedure is executed.
If the session is still open after deleting the cookies it could mean that the website is using an alternative method to keep the session open without cookies. Search "maintain sessions without cookies" in Google for more information about this.
You can use CookieVisitor to see if there's any cookie left after the TChromium.DeleteCookies procedure is executed.
- Run CookieVisitor and load your web page.
- Login in that web page.
- Right-click and select "Visit cookies" to see what cookies are available.
- A new window shows some cookie information if there are any cookie available.
- Right-click and select "Delete cookies".
- A message dialog informs that the cookies were deleted.
- Right-click and select "Visit cookies" to see what cookies are still available. If you don't see a new window with cookie information then it means that there are no cookies stored.
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Delete cookies
Thank you for the detailed information Salvador ! 
