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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

how to use SetContentSetting

Post Reply
Jerry
Posts: 1
Joined: Fri Aug 23, 2024 12:58 am

how to use SetContentSetting

Post by Jerry »

http://127.0.0.1:5000/cookie1
http://127.0.0.1:5000/cookie2
These two url requests return a cookie, which the front page displays.
I only want to control the COOKIE for the first URL, but the COOKIE for the second URL is also invalid。
Why is that? Am I using it wrong

Code: Select all

procedure TForm1.Chromium1RequestContextInitialized(Sender: TObject;
  const request_context: ICefRequestContext);
begin
  request_context.SetContentSetting(
	'http://127.0.0.1:5000/cookie1',
	'http://127.0.0.1:5000/cookie1',
	CEF_CONTENT_SETTING_TYPE_COOKIES,
	CEF_CONTENT_SETTING_VALUE_BLOCK
	);
end;
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: how to use SetContentSetting

Post by salvadordf »

These are the code comments for TCefRequestContextRef.SetContentSetting :

Code: Select all

      /// Sets the current value for |content_type| for the specified URLs in the
      /// default scope. If both URLs are NULL, and the context is not incognito,
      /// the default value will be set. Pass CEF_CONTENT_SETTING_VALUE_DEFAULT for
      /// |value| to use the default value for this content type.
      ///
      /// WARNING: Incorrect usage of this function may cause instability or
      /// security issues in Chromium. Make sure that you first understand the
      /// potential impact of any changes to |content_type| by reviewing the related
      /// source code in Chromium. For example, if you plan to modify
      /// CEF_CONTENT_SETTING_TYPE_POPUPS, first review and understand the usage of
      /// ContentSettingsType::POPUPS in Chromium:
      /// https://source.chromium.org/search?q=ContentSettingsType::POPUPS
I don't have much experience with that function but it seems that Chromium is applying the same setting for all the cookies from the same host regardless of the full URL path.
Post Reply