Edge中edge://settings/clearBrowsingDataOnClose网站列表存储位置及脚本添加方法
存储位置
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
相关产品推荐
相关产品推荐

