Page 1 of 1

TCefRequestRef synchronous cookies

Posted: Thu Mar 29, 2018 3:33 am
by blueflagbj
Hi,
I use TCefRequestRef like this:

Request := TCefRequestRef.New;
Request.Url := BaseURL + '/oauth-provider/api/login';
Request.Method := 'POST';
Header := TCefStringMultimapOwn.Create;
Header.Append('Accept', 'application/json, text/javascript, */*; q=0.01');
Header.Append('X-Requested-With', 'XMLHttpRequest');
Header.Append('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36');
Header.Append('Content-Type', 'application/x-www-form-urlencoded');
Header.Append('Accept-Encoding', 'gzip, deflate');
Header.Append('Accept-Language', 'en-US,en;q=0.9');
Request.SetHeaderMap(Header);
Data := TCefPostDataRef.New;
Request.PostData := Data;
Request.SetReferrer(BaseURL, REFERRER_POLICY_CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE);
chrm1.Browser.MainFrame.LoadRequest(Request);

It is found that cookie is not synchronized with mainframe,How do I deal with this problem

Re: TCefRequestRef synchronous cookies

Posted: Fri Mar 30, 2018 12:12 pm
by salvadordf
I've never used a TCefRequestRef but according to this post you only need to set a few flags to use the cookies :
http://magpcss.org/ceforum/viewtopic.php?f=6&t=11958

Try calling Request.SetFlags(UR_FLAG_ALLOW_CACHED_CREDENTIALS or UR_FLAG_ALLOW_COOKIES);

PS : I just realized that the name of the UR_FLAG_ALLOW_CACHED_CREDENTIALS constant should be UR_FLAG_ALLOW_STORED_CREDENTIALS. I'll update CEF4Delphi with this change soon.

Re: TCefRequestRef synchronous cookies

Posted: Tue Apr 03, 2018 3:50 am
by blueflagbj
thanks,
I solved this problem by try calling Request.SetFlags(UR_FLAG_ALLOW_STORED_CREDENTIALS);