CefSharp Wpf,多个实例的会话Cookie [英] CefSharp Wpf , Session Cookie for multiple instances

查看:131
本文介绍了CefSharp Wpf,多个实例的会话Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇CEF Sharp是否有可能,以某种方式将每个浏览器实例与其他实例隔离。

I am very curious if there is a possibility in CEF Sharp , somehow to isolate each instance of browser from other instances.

我正在创建4个浏览器实例。登录实例后,
也会立即另外3个实例也登录。

I am creating 4 instances of browser. Logging in on of the instances , immediately 3 other instances become logged in as well.

是否可以通过Nuget的最新版本实现某种方式

Is it possible to achieve somehow in Current version that we got from Nuget ?

推荐答案

截至修订版2040 ,CEF现在在请求上下文的基础上增加了对存储和权限(缓存,cookie,localStorage,访问授权等)的完全隔离的支持。

As of revision 2040, CEF now adds support for complete isolation of storage and permissions (cache, cookies, localStorage, access grants, etc) on a request context basis. This is also now in CEFSharp.

要确保多个实例之间没有会话重叠,只需创建一个新的RequestContextSettings对象,将PersistSessionCookies和/或PersistUserPreferences设置为false,然后在创建新的RequestContext时将其分配给浏览器-我不确定对于多个实例是否完全必要将它们设置为false,也许其他人可以提供一些信息。

To make sure that no sessions overlap between multiple instances, simply create a new RequestContextSettings object, set PersistSessionCookies and/or PersistUserPreferences to false, and assign it to your browser while creating a new RequestContext - I am not sure if setting them to false is completely necessary for multiple instances, maybe someone else can give some info on that.

//usually ChromiumWebBrowser setup goes above this

RequestContextSettings requestContextSettings = new RequestContextSettings();

requestContextSettings.PersistSessionCookies = false;
requestContextSettings.PersistUserPreferences = false;

webBrowser.RequestContext = new RequestContext(requestContextSettings);

这让我头疼了一段时间,看来终于解决了这个问题。

This had been giving me headaches for a while and this appears to finally solve that issue.

这篇关于CefSharp Wpf,多个实例的会话Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆