Welcome Guest Search | Active Topics | Sign In | Register

Deletion of Previous cookie in the web request Options
Aayushi
Posted: Wednesday, April 22, 2020 5:19:55 AM
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);
eo_support
Posted: Wednesday, April 22, 2020 1:20:47 PM
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!
Aayushi
Posted: Wednesday, April 22, 2020 1:29:41 PM
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.
eo_support
Posted: Thursday, April 23, 2020 10:21:20 AM
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.aspx

After 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!


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.