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.

TCefRequestRef synchronous cookies

Post Reply
blueflagbj
Posts: 8
Joined: Mon Jul 10, 2017 8:08 am

TCefRequestRef synchronous cookies

Post 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
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: TCefRequestRef synchronous cookies

Post 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.
blueflagbj
Posts: 8
Joined: Mon Jul 10, 2017 8:08 am

Re: TCefRequestRef synchronous cookies

Post by blueflagbj »

thanks,
I solved this problem by try calling Request.SetFlags(UR_FLAG_ALLOW_STORED_CREDENTIALS);
Post Reply