Welcome Guest Search | Active Topics | Sign In | Register

Why get the same cookie every time? Options
sexfio1
Posted: Wednesday, October 23, 2019 7:45:15 AM
Rank: Member
Groups: Member

Joined: 10/17/2019
Posts: 14
Code: Visual Basic.NET
Dim threadRunner As ThreadRunner
        Dim Wv As WebView
        Dim list As New List(Of String)

        For i = 1 To 5
            threadRunner = New ThreadRunner()

            Wv = threadRunner.CreateWebView()

            threadRunner.Send(Sub()
                                  Wv.LoadUrlAndWait("https://www.baidu.com/")
                              End Sub)

            Dim L As New List(Of String)
            Dim CookieCollection As EO.WebEngine.CookieCollection
            CookieCollection = Wv.Engine.CookieManager.GetCookies("https://www.baidu.com/", True)
            For j As Integer = 0 To CookieCollection.Count - 1
                L.Add(CookieCollection(j).Name & "=" & CookieCollection(j).Value)
            Next
            Dim s As String = Join(L.ToArray, "; ")
            list.Add(s)

            Wv.Engine.CookieManager.DeleteCookies(Nothing, Nothing)
            Wv.Close(True)
            Wv.Destroy()
            Wv.Dispose()
            threadRunner.Dispose()
        Next

        MessageBox.Show(String.Join(vbCrLf & vbCrLf, list))


5 times get the cookie as follows:
Code: HTML/ASPX
BIDUPSID=7D7818E7779ECB6872971E5E12A6A7DF; BAIDUID=6B79832B4098B33B5CE3D97E3F9CAF9C:FG=1; PSTM=1571818219; BD_UPN=12314453; delPer=0; BD_HOME=0; H_PS_PSSID=1454_21088_29567_29699_29221


BIDUPSID=7D7818E7779ECB6872971E5E12A6A7DF; BAIDUID=3DF977C3857A1AB2D413E65719F7587D:FG=1; PSTM=1571818274; delPer=0; BD_HOME=0; H_PS_PSSID=1452_21116_29911_29568_29220; BD_UPN=12314453


BIDUPSID=7D7818E7779ECB6872971E5E12A6A7DF; BAIDUID=1C8E4873EE3CFA001204A8693BF1AC6F:FG=1; PSTM=1571818275; delPer=0; BD_HOME=0; H_PS_PSSID=1447_21120_29567_29221_26350; BD_UPN=12314453


BIDUPSID=7D7818E7779ECB6872971E5E12A6A7DF; BAIDUID=9ECF16F6486AF2CDEB16620542BAF9C8:FG=1; PSTM=1571818281; delPer=0; BD_HOME=0; H_PS_PSSID=1420_21127_29567_29221_26350; BD_UPN=12314453


BIDUPSID=7D7818E7779ECB6872971E5E12A6A7DF; BAIDUID=5A15F955D4EF96AE3B959F7A2EB4F981:FG=1; PSTM=1571818282; delPer=0; BD_HOME=0; H_PS_PSSID=1452_21125_29904_29568_29220_26350_22160; BD_UPN=12314453


You can see that every the "BIDUPSID" key's value is the same, why ??? :-]
I think every time I get it, it's totally different. How I need to do ?
eo_support
Posted: Wednesday, October 23, 2019 10:43:36 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
This is a question for baidu, not for us. :)
sexfio1
Posted: Wednesday, October 23, 2019 11:38:54 AM
Rank: Member
Groups: Member

Joined: 10/17/2019
Posts: 14
eo_support wrote:
This is a question for baidu, not for us. :)


But if I open Baidu page repeatedly use traceless browser, inCookie the "BIDUPSID" key's value is different every time..... >.<
eo_support
Posted: Wednesday, October 23, 2019 12:33:35 PM
Rank: Administration
Groups: Administration

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

You can try these steps and see if it works for you:

1. Explicitly create an Engine object;
2. Set the Engine's CachePath;
3. Create a ThreadRunner with that Engine and use it to load the page;
4. Destroy the WebView and ThreadRunner;
5. Stop the Engine;
6. Delete the entire Engine.CachePath directory;

The issue you are running into could be because CookieManager.DeleteCookies works asynchronously in the background, so it does not guarantee the cookies are deleted when it returns.

Thanks!
sexfio1
Posted: Thursday, October 24, 2019 12:00:46 PM
Rank: Member
Groups: Member

Joined: 10/17/2019
Posts: 14
eo_support wrote:
Hi,

You can try these steps and see if it works for you:

1. Explicitly create an Engine object;
2. Set the Engine's CachePath;
3. Create a ThreadRunner with that Engine and use it to load the page;
4. Destroy the WebView and ThreadRunner;
5. Stop the Engine;
6. Delete the entire Engine.CachePath directory;

The issue you are running into could be because CookieManager.DeleteCookies works asynchronously in the background, so it does not guarantee the cookies are deleted when it returns.

Thanks!



Thank you very much. I succeeded in the test.
eo_support
Posted: Friday, October 25, 2019 3:25:35 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Great. Thanks for the update!


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.