|
Rank: Newbie Groups: Member
Joined: 7/30/2019 Posts: 3
|
I am creating a new WebVIew and adding a cookie token to my request. For deleting the previous cookie I am using deleteCookies method but due to its asynch nature somewhat its deleting the current cookie token and therefore fiddler shows no cookie token added.Can you tell me how to make it synchronous to avoid deleting my current cookie. My code for the webview :
WebView internalView = (WebView)session.RunWebViewCallback((WebView webView, object args) => { webView.RegisterJSExtensionFunction("viewLoadedEvent", new JSExtInvokeHandler(ViewLoadedClientSideEventHandler)); _currentSession = session; session.WebView.Engine.CookieManager.DeleteCookies(prevCookie); //for adding cookie in request EO.WebEngine.Cookie c = new EO.WebEngine.Cookie("VerificationCookie", cookieToken); c.HttpOnly = true; prevCookie = c.ToString(); session.WebView.BeforeRequestLoad += (object sender, BeforeRequestLoadEventArgs e) => { e.Request.Cookies.Add(c); }; webView.LoadHtmlAndWait(htmlBuilder.ToString()); return webView;
}, null);
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
There is no way to precisely control when the cookie is deleted due to the asynchronous nature of the call. However there are two different cookies that are related but not the same:
A. The cookie you sent to the server; B. The cookie the server sends to you;
In a "normal" scenario, cookie A comes from cookie B: the server sends you a cookie so that later you can send it back. In your case, it seems that cookie A comes from your code (not from B) and cookie B never existed. So there is really nothing for you to delete.
Hope this makes sense to you.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/30/2019 Posts: 3
|
thanks for the reply. but when i am commenting session.WebView.Engine.CookieManager.DeleteCookies(prevCookie); In fiddler i can see two different cookies added in the request. why is that and how can i add one cookie to the request.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, The second cookie must have come from the cookie jar that was already on the disk. You can try clear the cache folder first and see if you still see that cookie: https://www.essentialobjects.com/doc/eo.webengine.engine.cleanupcachefolders_overloads.aspxAfter you clear the cache folder, you should not see the second cookie on the initial request. If you see the second cookie after the initial request, then this cookie comes from your server. In that case you can use Fiddler to trace the response data and see why that cookie is sent back to you. Thanks!
|
|