Page 1 of 1
About SetCookie
Posted: Tue Dec 10, 2024 5:10 pm
by thefunkyjoint
Let's say i have JSON file with cookies from a logged account in a social network, and i want to import these cookies to CEF4Delphi, so the user get logged on CEF4Delphi too.
Is there a specific order that SetCookie should be called ? I mean, does i need to include the cookies before navigate to the social network page, or there is no difference ?
And in this situation (importing cookies from logged account), what should be the value of the same_site property ?
TCefCookieSameSite = (
CEF_COOKIE_SAME_SITE_UNSPECIFIED,
CEF_COOKIE_SAME_SITE_NO_RESTRICTION,
CEF_COOKIE_SAME_SITE_LAX_MODE,
CEF_COOKIE_SAME_SITE_STRICT_MODE
);
Re: About SetCookie
Posted: Tue Dec 10, 2024 6:10 pm
by thefunkyjoint
Anoquer question, please : every cookie i try to set with SetCookie, fails and return false... is there a way to debug why ? On UCefChromiumCore , the result is always false on :
Code: Select all
Result := TempManager.SetCookie(url, name_, value, domain, path,
secure, httponly, hasExpires,
creation, lastAccess, expires,
same_site, priority,
TempCallback);
I'm filling all parameters. What am i missing ?

Re: About SetCookie
Posted: Wed Dec 11, 2024 10:55 am
by salvadordf
thefunkyjoint wrote: Tue Dec 10, 2024 5:10 pm
Is there a specific order that SetCookie should be called ? I mean, does i need to include the cookies before navigate to the social network page, or there is no difference ?
I've never done that but I guess the cookies should be added before navigating to that website.
thefunkyjoint wrote: Tue Dec 10, 2024 5:10 pm
And in this situation (importing cookies from logged account), what should be the value of the same_site property ?
TCefCookieSameSite = (
CEF_COOKIE_SAME_SITE_UNSPECIFIED,
CEF_COOKIE_SAME_SITE_NO_RESTRICTION,
CEF_COOKIE_SAME_SITE_LAX_MODE,
CEF_COOKIE_SAME_SITE_STRICT_MODE
);
Read that value from the
same_site argument in the TChromium.OnCookiesVisited event.
Read this for more information :
https://www.chromium.org/updates/same-site/faq/
https://source.chromium.org/chromium/chromium/src/+/main:docs/website/site/administrators/policy-list-3/cookie-legacy-samesite-policies/index.md
thefunkyjoint wrote: Tue Dec 10, 2024 6:10 pm
Anoquer question, please : every cookie i try to set with SetCookie, fails and return false... is there a way to debug why ? On UCefChromiumCore , the result is always false on :
Code: Select all
Result := TempManager.SetCookie(url, name_, value, domain, path,
secure, httponly, hasExpires,
creation, lastAccess, expires,
same_site, priority,
TempCallback);
I'm filling all parameters. What am i missing ?
These are the code comments for ICefCookieManager.SetCookie :
Code: Select all
/// Sets a cookie given a valid URL and explicit user-provided cookie
/// attributes. This function expects each attribute to be well-formed. It
/// will check for disallowed characters (e.g. the ';' character is disallowed
/// within the cookie value attribute) and fail without setting the cookie if
/// such characters are found. If |callback| is non-NULL it will be executed
/// asnychronously on the UI thread after the cookie has been set. Returns
/// false (0) if an invalid URL is specified or if cookies cannot be accessed.