cookie.html 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. <!doctype html>
  2. <html lang="zh" class="no-js">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <meta name="description" content="Net document">
  7. <meta name="author" content="劉強東">
  8. <link rel="prev" href="https.html">
  9. <link rel="next" href="cache.html">
  10. <link rel="icon" href="img/book-open.svg">
  11. <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.5.48">
  12. <title>Cookie - Net</title>
  13. <link rel="stylesheet" href="assets/stylesheets/main.6f8fc17f.min.css">
  14. <link rel="stylesheet" href="assets/stylesheets/palette.06af60db.min.css">
  15. <script src="https://unpkg.com/iframe-worker/shim"></script>
  16. <link rel="stylesheet" href="css/extra.css">
  17. <script>__md_scope=new URL(".",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
  18. </head>
  19. <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="white" data-md-color-accent="indigo">
  20. <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
  21. <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
  22. <label class="md-overlay" for="__drawer"></label>
  23. <div data-md-component="skip">
  24. </div>
  25. <div data-md-component="announce">
  26. </div>
  27. <header class="md-header md-header--shadow" data-md-component="header">
  28. <nav class="md-header__inner md-grid" aria-label="页眉">
  29. <a href="index.html" title="Net" class="md-header__button md-logo" aria-label="Net" data-md-component="logo">
  30. <img src="img/book-open.svg" alt="logo">
  31. </a>
  32. <label class="md-header__button md-icon" for="__drawer">
  33. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
  34. </label>
  35. <div class="md-header__title" data-md-component="header-title">
  36. <div class="md-header__ellipsis">
  37. <div class="md-header__topic">
  38. <span class="md-ellipsis">
  39. Net
  40. </span>
  41. </div>
  42. <div class="md-header__topic" data-md-component="header-topic">
  43. <span class="md-ellipsis">
  44. Cookie
  45. </span>
  46. </div>
  47. </div>
  48. </div>
  49. <form class="md-header__option" data-md-component="palette">
  50. <input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="white" data-md-color-accent="indigo" aria-hidden="true" type="radio" name="__palette" id="__palette_0">
  51. </form>
  52. <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
  53. <label class="md-header__button md-icon" for="__search">
  54. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
  55. </label>
  56. <div class="md-search" data-md-component="search" role="dialog">
  57. <label class="md-search__overlay" for="__search"></label>
  58. <div class="md-search__inner" role="search">
  59. <form class="md-search__form" name="search">
  60. <input type="text" class="md-search__input" name="query" aria-label="搜索" placeholder="搜索" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
  61. <label class="md-search__icon md-icon" for="__search">
  62. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
  63. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
  64. </label>
  65. <nav class="md-search__options" aria-label="查找">
  66. <a href="javascript:void(0)" class="md-search__icon md-icon" title="分享" aria-label="分享" data-clipboard data-clipboard-text="" data-md-component="search-share" tabindex="-1">
  67. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.15c-.05.21-.08.43-.08.66 0 1.61 1.31 2.91 2.92 2.91s2.92-1.3 2.92-2.91A2.92 2.92 0 0 0 18 16.08"/></svg>
  68. </a>
  69. <button type="reset" class="md-search__icon md-icon" title="清空当前内容" aria-label="清空当前内容" tabindex="-1">
  70. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
  71. </button>
  72. </nav>
  73. <div class="md-search__suggest" data-md-component="search-suggest"></div>
  74. </form>
  75. <div class="md-search__output">
  76. <div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
  77. <div class="md-search-result" data-md-component="search-result">
  78. <div class="md-search-result__meta">
  79. 正在初始化搜索引擎
  80. </div>
  81. <ol class="md-search-result__list" role="presentation"></ol>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="md-header__source">
  88. <a href="https://github.com/liangjingkanji/Net" title="前往仓库" class="md-source" data-md-component="source">
  89. <div class="md-source__icon md-icon">
  90. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
  91. </div>
  92. <div class="md-source__repository">
  93. GitHub
  94. </div>
  95. </a>
  96. </div>
  97. </nav>
  98. </header>
  99. <div class="md-container" data-md-component="container">
  100. <main class="md-main" data-md-component="main">
  101. <div class="md-main__inner md-grid">
  102. <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
  103. <div class="md-sidebar__scrollwrap">
  104. <div class="md-sidebar__inner">
  105. <nav class="md-nav md-nav--primary" aria-label="导航栏" data-md-level="0">
  106. <label class="md-nav__title" for="__drawer">
  107. <a href="index.html" title="Net" class="md-nav__button md-logo" aria-label="Net" data-md-component="logo">
  108. <img src="img/book-open.svg" alt="logo">
  109. </a>
  110. Net
  111. </label>
  112. <div class="md-nav__source">
  113. <a href="https://github.com/liangjingkanji/Net" title="前往仓库" class="md-source" data-md-component="source">
  114. <div class="md-source__icon md-icon">
  115. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
  116. </div>
  117. <div class="md-source__repository">
  118. GitHub
  119. </div>
  120. </a>
  121. </div>
  122. <ul class="md-nav__list" data-md-scrollfix>
  123. <li class="md-nav__item">
  124. <a href="index.html" class="md-nav__link">
  125. <span class="md-ellipsis">
  126. 使用
  127. </span>
  128. </a>
  129. </li>
  130. <li class="md-nav__item">
  131. <a href="coroutine-request.html" class="md-nav__link">
  132. <span class="md-ellipsis">
  133. 协程请求
  134. </span>
  135. </a>
  136. </li>
  137. <li class="md-nav__item">
  138. <a href="scope.html" class="md-nav__link">
  139. <span class="md-ellipsis">
  140. 作用域
  141. </span>
  142. </a>
  143. </li>
  144. <li class="md-nav__item">
  145. <a href="sync-request.html" class="md-nav__link">
  146. <span class="md-ellipsis">
  147. 同步请求
  148. </span>
  149. </a>
  150. </li>
  151. <li class="md-nav__item">
  152. <a href="request.html" class="md-nav__link">
  153. <span class="md-ellipsis">
  154. 请求参数
  155. </span>
  156. </a>
  157. </li>
  158. <li class="md-nav__item">
  159. <a href="config.html" class="md-nav__link">
  160. <span class="md-ellipsis">
  161. 全局配置
  162. </span>
  163. </a>
  164. </li>
  165. <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
  166. <a href="converter.html" class="md-nav__link">
  167. <span class="md-ellipsis">
  168. 请求结果
  169. </span>
  170. <span class="md-nav__icon md-icon"></span>
  171. </a>
  172. </li>
  173. <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
  174. <a href="auto-dialog.html" class="md-nav__link">
  175. <span class="md-ellipsis">
  176. 自动化
  177. </span>
  178. <span class="md-nav__icon md-icon"></span>
  179. </a>
  180. </li>
  181. <li class="md-nav__item">
  182. <a href="thread.html" class="md-nav__link">
  183. <span class="md-ellipsis">
  184. 切换线程
  185. </span>
  186. </a>
  187. </li>
  188. <li class="md-nav__item">
  189. <a href="view-model.html" class="md-nav__link">
  190. <span class="md-ellipsis">
  191. ViewModel
  192. </span>
  193. </a>
  194. </li>
  195. <li class="md-nav__item">
  196. <a href="track.html" class="md-nav__link">
  197. <span class="md-ellipsis">
  198. 异常追踪
  199. </span>
  200. </a>
  201. </li>
  202. <li class="md-nav__item md-nav__item--pruned md-nav__item--nested">
  203. <a href="error.html" class="md-nav__link">
  204. <span class="md-ellipsis">
  205. 错误处理
  206. </span>
  207. <span class="md-nav__icon md-icon"></span>
  208. </a>
  209. </li>
  210. <li class="md-nav__item">
  211. <a href="okhttp-client.html" class="md-nav__link">
  212. <span class="md-ellipsis">
  213. OkHttpClient
  214. </span>
  215. </a>
  216. </li>
  217. <li class="md-nav__item">
  218. <a href="interceptor.html" class="md-nav__link">
  219. <span class="md-ellipsis">
  220. 拦截器
  221. </span>
  222. </a>
  223. </li>
  224. <li class="md-nav__item">
  225. <a href="https.html" class="md-nav__link">
  226. <span class="md-ellipsis">
  227. Https证书
  228. </span>
  229. </a>
  230. </li>
  231. <li class="md-nav__item md-nav__item--active">
  232. <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
  233. <a href="cookie.html" class="md-nav__link md-nav__link--active">
  234. <span class="md-ellipsis">
  235. Cookie
  236. </span>
  237. </a>
  238. </li>
  239. <li class="md-nav__item">
  240. <a href="cache.html" class="md-nav__link">
  241. <span class="md-ellipsis">
  242. 缓存
  243. </span>
  244. </a>
  245. </li>
  246. <li class="md-nav__item">
  247. <a href="tag.html" class="md-nav__link">
  248. <span class="md-ellipsis">
  249. 标签/额外
  250. </span>
  251. </a>
  252. </li>
  253. <li class="md-nav__item">
  254. <a href="upload-file.html" class="md-nav__link">
  255. <span class="md-ellipsis">
  256. 上传文件
  257. </span>
  258. </a>
  259. </li>
  260. <li class="md-nav__item">
  261. <a href="download-file.html" class="md-nav__link">
  262. <span class="md-ellipsis">
  263. 下载文件
  264. </span>
  265. </a>
  266. </li>
  267. <li class="md-nav__item">
  268. <a href="progress.html" class="md-nav__link">
  269. <span class="md-ellipsis">
  270. 进度监听
  271. </span>
  272. </a>
  273. </li>
  274. <li class="md-nav__item">
  275. <a href="cancel.html" class="md-nav__link">
  276. <span class="md-ellipsis">
  277. 取消请求
  278. </span>
  279. </a>
  280. </li>
  281. <li class="md-nav__item">
  282. <a href="repeat-request.html" class="md-nav__link">
  283. <span class="md-ellipsis">
  284. 重复请求
  285. </span>
  286. </a>
  287. </li>
  288. <li class="md-nav__item">
  289. <a href="debounce.html" class="md-nav__link">
  290. <span class="md-ellipsis">
  291. 搜索节流
  292. </span>
  293. </a>
  294. </li>
  295. <li class="md-nav__item">
  296. <a href="fastest.html" class="md-nav__link">
  297. <span class="md-ellipsis">
  298. 最快请求结果
  299. </span>
  300. </a>
  301. </li>
  302. <li class="md-nav__item">
  303. <a href="log-recorder.html" class="md-nav__link">
  304. <span class="md-ellipsis">
  305. 日志插件
  306. </span>
  307. </a>
  308. </li>
  309. <li class="md-nav__item">
  310. <a href="log-notice.html" class="md-nav__link">
  311. <span class="md-ellipsis">
  312. 日志通知
  313. </span>
  314. </a>
  315. </li>
  316. <li class="md-nav__item">
  317. <a href="timing.html" class="md-nav__link">
  318. <span class="md-ellipsis">
  319. 限时/定时请求
  320. </span>
  321. </a>
  322. </li>
  323. <li class="md-nav__item">
  324. <a href="callback.html" class="md-nav__link">
  325. <span class="md-ellipsis">
  326. Callback
  327. </span>
  328. </a>
  329. </li>
  330. <li class="md-nav__item">
  331. <a href="interval.html" class="md-nav__link">
  332. <span class="md-ellipsis">
  333. 轮询器/倒计时
  334. </span>
  335. </a>
  336. </li>
  337. <li class="md-nav__item">
  338. <a href="https://github.com/liangjingkanji/Net/discussions" class="md-nav__link">
  339. <span class="md-ellipsis">
  340. 社区讨论
  341. </span>
  342. </a>
  343. </li>
  344. <li class="md-nav__item">
  345. <a href="issues.html" class="md-nav__link">
  346. <span class="md-ellipsis">
  347. 常见问题
  348. </span>
  349. </a>
  350. </li>
  351. <li class="md-nav__item">
  352. <a href="updates.html" class="md-nav__link">
  353. <span class="md-ellipsis">
  354. 更新日志
  355. </span>
  356. </a>
  357. </li>
  358. <li class="md-nav__item">
  359. <a href="api/index.html" class="md-nav__link">
  360. <span class="md-ellipsis">
  361. 3.x文档
  362. </span>
  363. </a>
  364. </li>
  365. </ul>
  366. </nav>
  367. </div>
  368. </div>
  369. </div>
  370. <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
  371. <div class="md-sidebar__scrollwrap">
  372. <div class="md-sidebar__inner">
  373. <nav class="md-nav md-nav--secondary" aria-label="目录">
  374. </nav>
  375. </div>
  376. </div>
  377. </div>
  378. <div class="md-content" data-md-component="content">
  379. <article class="md-content__inner md-typeset">
  380. <h1>Cookie</h1>
  381. <p>可以实现OkHttp的<code>CookieJar</code>, 且提供持久化的<a href="https://github.com/liangjingkanji/Net/blob/2abf07e1d003ef44574278fd2010f3375225d964/net/src/main/java/com/drake/net/cookie/PersistentCookieJar.kt">PersistentCookieJar</a></p>
  382. <div class="language-kotlin highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="n">NetConfig</span><span class="p">.</span><span class="na">initialize</span><span class="p">(</span><span class="n">Api</span><span class="p">.</span><span class="na">HOST</span><span class="p">,</span><span class="w"> </span><span class="k">this</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
  383. </span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a><span class="w"> </span><span class="c1">// 添加持久化Cookie</span>
  384. </span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="w"> </span><span class="n">cookieJar</span><span class="p">(</span><span class="n">PersistentCookieJar</span><span class="p">(</span><span class="k">this</span><span class="nd">@App</span><span class="p">))</span>
  385. </span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a><span class="p">}</span>
  386. </span></code></pre></div>
  387. <p>可以手动增删Cookie</p>
  388. <table>
  389. <thead>
  390. <tr>
  391. <th>PersistentCookieJar</th>
  392. <th>描述</th>
  393. </tr>
  394. </thead>
  395. <tbody>
  396. <tr>
  397. <td>addAll</td>
  398. <td>添加Cookie</td>
  399. </tr>
  400. <tr>
  401. <td>getAll</td>
  402. <td>获取某个域名的所有Cookie</td>
  403. </tr>
  404. <tr>
  405. <td>remove</td>
  406. <td>删除某个域名下所有或者指定名称的Cookie</td>
  407. </tr>
  408. <tr>
  409. <td>clear</td>
  410. <td>删除客户端全部Cookie</td>
  411. </tr>
  412. </tbody>
  413. </table>
  414. <p>可通过客户端获取到已配置cookieJar
  415. <div class="language-kotlin highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a><span class="p">(</span><span class="n">NetConfig</span><span class="p">.</span><span class="na">okHttpClient</span><span class="p">.</span><span class="na">cookieJar</span><span class="w"> </span><span class="k">as?</span><span class="w"> </span><span class="n">PersistentCookieJar</span><span class="p">)</span><span class="o">?.</span><span class="na">clear</span><span class="p">()</span>
  416. </span></code></pre></div></p>
  417. <div class="admonition note">
  418. <p class="admonition-title">隔绝Cookies共享</p>
  419. <p>为<code>PersistentCookieJar</code>指定不同<code>dbName</code>阻止不同的客户端共享Cookies</p>
  420. </div>
  421. </article>
  422. </div>
  423. <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
  424. </div>
  425. <button type="button" class="md-top md-icon" data-md-component="top" hidden>
  426. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg>
  427. 回到页面顶部
  428. </button>
  429. </main>
  430. <!-- Footer -->
  431. <footer class="md-footer">
  432. <!-- Link to previous and/or next page -->
  433. <nav class="md-footer__inner md-grid" aria-label="footer.title">
  434. <!-- Link to previous page -->
  435. <a href="https.html" class="md-footer__link md-footer__link--prev" rel="prev">
  436. <div class="md-footer__button md-icon">
  437. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
  438. </div>
  439. <div class="md-footer__title">
  440. <div class="md-ellipsis">
  441. <span class="md-footer__direction">
  442. 上一页
  443. </span>
  444. Https证书
  445. </div>
  446. </div>
  447. </a>
  448. <!-- Link to next page -->
  449. <a href="cache.html" class="md-footer__link md-footer__link--next" rel="next">
  450. <div class="md-footer__title">
  451. <div class="md-ellipsis">
  452. <span class="md-footer__direction">
  453. 下一页
  454. </span>
  455. 缓存
  456. </div>
  457. </div>
  458. <div class="md-footer__button md-icon">
  459. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11z"/></svg>
  460. </div>
  461. </a>
  462. </nav>
  463. <!-- Further information -->
  464. <div class="md-footer-meta md-typeset">
  465. <div class="md-footer-meta__inner md-grid">
  466. <!-- Copyright and theme information -->
  467. <div class="md-footer-copyright">
  468. <a href="https://github.com/liangjingkanji" target="_blank" rel="noopener">
  469. <div class="md-footer-copyright__highlight">
  470. Copyright &copy; 2018 - 2023 劉強東
  471. </div>
  472. </a>
  473. </div>
  474. <!-- Social links -->
  475. <div class="md-social">
  476. <a href="https://github.com/liangjingkanji" target="_blank" rel="noopener" title="github.com" class="md-social__link">
  477. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2"/></svg>
  478. </a>
  479. <a href="https://raw.githubusercontent.com/liangjingkanji/liangjingkanji/master/img/group-qrcode.png" target="_blank" rel="noopener" title="raw.githubusercontent.com" class="md-social__link">
  480. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M433.754 420.445c-11.526 1.393-44.86-52.741-44.86-52.741 0 31.345-16.136 72.247-51.051 101.786 16.842 5.192 54.843 19.167 45.803 34.421-7.316 12.343-125.51 7.881-159.632 4.037-34.122 3.844-152.316 8.306-159.632-4.037-9.045-15.25 28.918-29.214 45.783-34.415-34.92-29.539-51.059-70.445-51.059-101.792 0 0-33.334 54.134-44.859 52.741-5.37-.65-12.424-29.644 9.347-99.704 10.261-33.024 21.995-60.478 40.144-105.779C60.683 98.063 108.982.006 224 0c113.737.006 163.156 96.133 160.264 214.963 18.118 45.223 29.912 72.85 40.144 105.778 21.768 70.06 14.716 99.053 9.346 99.704"/></svg>
  481. </a>
  482. <a href="https://github.com/liangjingkanji/Net/discussions" target="_blank" rel="noopener" title="github.com" class="md-social__link">
  483. <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M391.17 103.47h-38.63v109.7h38.63ZM285 103h-38.63v109.75H285ZM120.83 0 24.31 91.42v329.16h115.83V512l96.53-91.42h77.25L487.69 256V0Zm328.24 237.75-77.22 73.12h-77.24l-67.6 64v-64h-86.87V36.58h308.93Z"/></svg>
  484. </a>
  485. </div>
  486. </div>
  487. </div>
  488. </footer>
  489. </div>
  490. <div class="md-dialog" data-md-component="dialog">
  491. <div class="md-dialog__inner md-typeset"></div>
  492. </div>
  493. <script id="__config" type="application/json">{"base": ".", "features": ["navigation.top", "navigation.prune", "navigation.footer", "navigation.instant", "search.highlight", "search.suggest", "search.share", "content.code.copy", "content.code.annotate"], "search": "assets/javascripts/workers/search.6ce7567c.min.js", "translations": {"clipboard.copied": "\u5df2\u590d\u5236", "clipboard.copy": "\u590d\u5236", "search.result.more.one": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.more.other": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 # \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.none": "\u6ca1\u6709\u627e\u5230\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.one": "\u627e\u5230 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.other": "# \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.placeholder": "\u952e\u5165\u4ee5\u5f00\u59cb\u641c\u7d22", "search.result.term.missing": "\u7f3a\u5c11", "select.version": "\u9009\u62e9\u5f53\u524d\u7248\u672c"}}</script>
  494. <script src="assets/javascripts/bundle.83f73b43.min.js"></script>
  495. </body>
  496. </html>