You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Edge中edge://settings/clearBrowsingDataOnClose网站列表存储位置及脚本添加方法

Edge 关闭浏览器时保留Cookie的网站列表存储位置与脚本添加方法

存储位置

Edge中「关闭浏览器时不清除Cookie的网站」列表并非存储在注册表中,而是保存在用户数据目录下的Preferences JSON文件里,具体路径:

  • Windows:%LOCALAPPDATA%\Microsoft\Edge\User Data\Default\Preferences
  • macOS:~/Library/Application Support/Microsoft/Edge/Default/Preferences
  • Linux:~/.config/microsoft-edge/Default/Preferences

该文件中对应字段为profile.cookie_exception_list,每个保留Cookie的网站以域名作为键,值为固定结构:{"expiration": "0", "type": "allow"}。

脚本/命令行添加方法

前提:先关闭所有Edge进程

修改文件前必须确保Edge完全关闭,否则修改内容会被进程覆盖。以Windows为例:

Stop-Process -Name msedge -Force

Windows PowerShell 示例

以下脚本可添加指定网站到保留列表:

# 定义要添加的网站域名(前缀加.表示包含子域名)
$targetSite = ".example.com"

# 读取Preferences文件路径
$prefsPath = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Preferences"

# 加载并解析JSON配置
$prefsContent = Get-Content $prefsPath -Raw | ConvertFrom-Json

# 添加网站到Cookie例外列表
$prefsContent.profile.cookie_exception_list | Add-Member -MemberType NoteProperty -Name $targetSite -Value @{expiration = "0"; type = "allow"} -Force

# 将修改后的配置写回文件(-Depth 100避免JSON序列化截断)
$prefsContent | ConvertTo-Json -Depth 100 | Set-Content $prefsPath

注意事项

  • 如果使用多用户配置文件,需将路径中的Default替换为对应配置文件夹(如Profile 1)。
  • 修改后重新启动Edge,即可在edge://settings/clearBrowsingDataOnClose页面看到添加的网站。

内容的提问来源于stack exchange,提问作者NutCracker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 18:24:26