How to set Cookies in cefglue 2623

289 views
Skip to first unread message

Sai Prasad

unread,
Oct 4, 2016, 8:37:03 AM10/4/16
to CefGlue
Dear Dmitry:

I am using cefglue 2623 and I have a scenario to set the cookies in winforms application which is using xilium.cefglue, I have found the below code to set the cookie 

CefCookie cookie = new CefCookie();
                    cookie.Domain = null;
                    cookie.Expires = null;
                    cookie.Name = "Sample";
                    cookie.Path = "/";
                    cookie.Value = "SampleTesting";
                    CefCookieManager.Global.SetCookie(url, cookie);

but am not able to find the Global method to set the cookie in the CefCookieManager class can you please help me out to achieve this.

Regards,
Sai Prasad

Dmitry Azaraev

unread,
Oct 4, 2016, 11:26:16 AM10/4/16
to CefGlue
Hello.

CefCookieManager::GetGlobal is your's method.

PS: Also always check SetCookie result. If you need to set cookie with domain, then url's domain should match.

--
You received this message because you are subscribed to the Google Groups "CefGlue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cefglue+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sai Prasad

unread,
Oct 5, 2016, 5:41:02 AM10/5/16
to CefGlue, dmitry....@gmail.com
Hi Dmitry,

Can you please give me any example reference which will helpful for me to just set the cookie.

Sai Prasad

unread,
Oct 5, 2016, 5:50:56 AM10/5/16
to CefGlue, dmitry....@gmail.com
Hi Dmitry,

Can you please give me any example reference which will helpful for me to just set already existing cookie with out creation.

Dmitry Azaraev

unread,
Oct 5, 2016, 1:13:02 PM10/5/16
to CefGlue
You aldeady had example. It should work.
Also dont ignore docs. Ask concrete questions please. For general CEF API questions it may be more helpful ask on ceforum.

Sai Prasad

unread,
Oct 6, 2016, 5:46:57 AM10/6/16
to CefGlue, dmitry....@gmail.com
Hi Dmitry,

Yes I have am example but the thing am not able to find setcookie method it has only create method, do I need to override the cefcookiemanager ?

Dmitry Azaraev

unread,
Oct 6, 2016, 5:52:02 AM10/6/16
to CefGlue
Hi.

1. Get CefCookieManager: for global request context it can be done by calling CefCookieManager.GetGlobal(null).
2. Then cookieManager.SetCookie(...).

Sai Prasad

unread,
Oct 12, 2016, 12:21:01 AM10/12/16
to CefGlue, dmitry....@gmail.com
Hi Dmitry,

Am able to set the cookie as suggested by you, but I have few clarifications 
1. I have set the cookie after the initialization of cefruntime .... is this the right way ?
2. I tried with setting the cookie in the cefbrowser load end event ..... is this the right way ?
3. I have tried with the above two ways with out any exception, but when try to read the cookie using cefcookievisitor am not able to find the value which is set by cefcookiemanager 

Dmitry Azaraev

unread,
Oct 12, 2016, 3:55:08 AM10/12/16
to Sai Prasad, CefGlue

1. Yes.
2. No, normally they should be set before.
3. Check result of SetCookie method. If uou provide wrong data it returns false.

Sai Prasad

unread,
Oct 13, 2016, 1:19:53 AM10/13/16
to CefGlue
Hi Dmitry,

Thanks for the suggestion it works, the problem is with cookie value I have not used Uri.EscapeDataString("") to set cookie value
Reply all
Reply to author
Forward
0 new messages