Page 1 of 1

Re: How delete domain cookies

Posted: Wed May 23, 2018 5:14 pm
by salvadordf
There are 2 ways to do that :
  • Create a similar function to TChromium.DeleteCookies and call TempManager.DeleteCookies(URL, CookieName, nil) with a custom URL and CookieName. You can use just the URL and leave the CookieName blank.
  • Use the code in the CookieVisitor demo. Set deleteCookie to TRUE in the CookieVisitorProc procedure when domain has the right value.

Re: How delete domain cookies

Posted: Wed May 23, 2018 5:15 pm
by salvadordf
The CEF code comments for DeleteCookies are these :

Code: Select all

  ///
  // Delete all cookies that match the specified parameters. If both |url| and
  // |cookie_name| values are specified all host and domain cookies matching
  // both will be deleted. If only |url| is specified all host cookies (but not
  // domain cookies) irrespective of path will be deleted. If |url| is NULL all
  // cookies for all hosts and domains will be deleted. If |callback| is non-
  // NULL it will be executed asnychronously on the IO thread after the cookies
  // have been deleted. Returns false (0) if a non-NULL invalid URL is specified
  // or if cookies cannot be accessed. Cookies can alternately be deleted using
  // the Visit*Cookies() functions.
  ///

Re: How delete domain cookies

Posted: Mon May 28, 2018 3:47 pm
by salvadordf
I added the url and cookieName parameters to TChromium.DeleteCookies a few days ago.
Download the latest version of CEF4Delphi and call TChromium.DeleteCookies(myUrl) or TChromium.DeleteCookies(myUrl, myCookieName) if you want to delete the cookies that match myUrl and myCookieName.

If you prefer the second way to delete cookies, just modify the CookieVisitorProc procedure in uCookieVisitor.pas from the CookieVisitor demo. Replace the line 149 with something like this :

Code: Select all

deleteCookie := domain = 'google.com';
That will delete all the cookies from the google.com domain.

Re: How delete domain cookies

Posted: Tue May 29, 2018 8:12 am
by salvadordf
Both methods delete cookies in a different way. This is what the CEF code comments say about using the "DeleteCookies" function :

Code: Select all

If only |url| is specified all host cookies (but not domain cookies) irrespective of path will be deleted.
If you need absolute control about the conditions to delete any cookie modify CookieVisitorProc from the CookieVisitor demo and set deleteCookie to TRUE when you receive certain domain, path, name, etc.

Re: How delete domain cookies

Posted: Tue May 29, 2018 12:18 pm
by salvadordf
If you need to delete all cookies from google.com check that the domain parameter ends with '.google.com' and set deleteCookie to TRUE.

For more information about cookie domains read this :
https://stackoverflow.com/questions/106 ... mains-work