Welcome Guest Search | Active Topics | Sign In | Register

Unable to get cookies Options
KimmyS
Posted: Wednesday, November 4, 2020 12:35:02 PM
Rank: Newbie
Groups: Member

Joined: 11/4/2020
Posts: 2
Using EO.WebBrowser I am unable to fetch cookies as I should've been able to.
Even with having IncludeHttpOnly cookies flag on to no avail.
eo_support
Posted: Wednesday, November 4, 2020 7:13:40 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,066
Hi,

Please provide more details on how you fetch the cookies and then we can go from there.

Thanks!
KimmyS
Posted: Thursday, November 5, 2020 1:54:32 AM
Rank: Newbie
Groups: Member

Joined: 11/4/2020
Posts: 2
eo_support wrote:
Hi,

Please provide more details on how you fetch the cookies and then we can go from there.

Thanks!


Quote:
Dim x = EO.WebEngine.Engine.Default.CookieManager.GetCookies()
Dim host_cookie = ""
Dim yy As Cookie
Dim c = ""
MessageBox.Show(x.Count)
For Each m In x


yy = x.Get(m)
c += yy.Domain + " " + m + "=" + yy.Value.ToString() + vbNewLine
Next
MessageBox.Show(c)


This is how I fetch cookies, but unfortunately not able to grab the cookies even though fiddler shows the cookies being transmitted and are in every request.
eo_support
Posted: Thursday, November 5, 2020 7:02:26 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,066
Hi,

In that case you can try to isolate the problem into a test project and send the test project to us. See here for more details:

https://www.essentialobjects.com/forum/test_project.aspx

After we receive the test project, we will be happy to investigate further.

Thanks!
rainstuff
Posted: Thursday, November 12, 2020 3:13:44 PM
Rank: Advanced Member
Groups: Member

Joined: 9/20/2016
Posts: 72
Chromium cookies are stored in the "Cookies" file by default. This file is actually a SQLite base and can be opened in any SQLite viewer.
Previously, cookie values were stored in the "value" column, but in recent chrome builds this column is "<NULL>" and all values are stored in the "encrypted_val" column. So you need to decode them before using. Maybe that's the problem.

Starting Chrome 80 version, cookies are encrypted using the AES256-GCM algorithm, and the AES encryption key is encrypted with the DPAPI encryption system, and the encrypted key is stored inside the ‘Local State’ file.
I also cannot get the cookies correctly from WebBrowser on chromium v81.0.4044.113, so I roll back to WebBrowser on chromium v70.0.3538.77

Is there a way to disable cookie encryption?

eo_support
Posted: Friday, November 13, 2020 3:37:46 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,066
rainstuff wrote:
Chromium cookies are stored in the "Cookies" file by default. This file is actually a SQLite base and can be opened in any SQLite viewer.
Previously, cookie values were stored in the "value" column, but in recent chrome builds this column is "<NULL>" and all values are stored in the "encrypted_val" column. So you need to decode them before using. Maybe that's the problem.

Starting Chrome 80 version, cookies are encrypted using the AES256-GCM algorithm, and the AES encryption key is encrypted with the DPAPI encryption system, and the encrypted key is stored inside the ‘Local State’ file.
I also cannot get the cookies correctly from WebBrowser on chromium v81.0.4044.113, so I roll back to WebBrowser on chromium v70.0.3538.77

Is there a way to disable cookie encryption?


You are not suppose to access cookie that way. We will only support methods provided by our API. We are not in a position to provide you support on how to "hack" Chromium browser engine.
rainstuff
Posted: Saturday, November 14, 2020 5:53:43 PM
Rank: Advanced Member
Groups: Member

Joined: 9/20/2016
Posts: 72
KimmyS wrote:
eo_support wrote:
Hi,

Please provide more details on how you fetch the cookies and then we can go from there.

Thanks!


This is how I fetch cookies, but unfortunately not able to grab the cookies even though fiddler shows the cookies being transmitted and are in every request.


Hi, KimmyS!

This is part of my code in C# and it works on latest version EO.Total 20.2.90:

Code: C#
EO.WebBrowser.WinForm.WebControl wc = GetCurrentWebControl(); 
                   var shost="google.com";
                   var cookieCollection = wc.WebView.Engine.CookieManager.GetCookies("", false);
                    Dictionary<string, string> cookDict = new Dictionary<string, string>(); 
                    foreach(var cc in cookieCollection.AllKeys)
                    {
                        if ((
                            ((cookieCollection[cc].Expires < DateTime.Now) && (cookieCollection[cc].Expires.Kind == DateTimeKind.Local))||
                            ((cookieCollection[cc].Expires < DateTime.UtcNow) && (cookieCollection[cc].Expires.Kind == DateTimeKind.Utc))
                           )&&
                          (cookieCollection[cc].Expires.Kind!=DateTimeKind.Unspecified)) continue;
                      if (
                           cookieCollection[cc].Domain.Contains("." + shost) || cookieCollection[cc].Domain.Equals(shost) 
                          )
                      {
                          if (cookDict.ContainsKey(cc)) 
                          {
                              cookDict[cc] = cookieCollection[cc].Value;
                          }else 
                          {
                              cookDict.Add(cc, cookieCollection[cc].Value); 
                          }
                      }
                    }
                    var cooks=cookDict.ToCookieString();


ToCookieString() is an extension:

Code: C#
static class ControlExtensions
    {
        public static string ToCookieString<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)
        {
            return string.Join(Environment.NewLine, dictionary.Select(kv => kv.Key + "=" + kv.Value).ToArray());
        }
    }


P.S. I found a way to encrypt/decrypt cookies directly in Cookies file on Chromium v80 and later, so the problem is solved:)


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.