Page 1 of 1

how to use SetContentSetting

Posted: Fri Aug 23, 2024 1:12 am
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;

Re: how to use SetContentSetting

Posted: Sun Aug 25, 2024 5:06 pm
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.