chrome.cookies
文章推薦指數: 80 %
Use the chrome.cookies API to query and modify cookies, and to be notified when they change. Permissions. cookies.
SkiptocontentHomeDocsBlogHomeDocsBlogExtensionsWelcomeWhat'snewinChromeextensionsGettingstartedIntroducingManifestV3WelcometoManifestV3ExtensionsplatformvisionOverviewofManifestV3MigratingtoManifestV3ManifestV3migrationchecklistManifestV2supporttimelineOverviewWhatareextensions?Whatarethemes?FrequentlyaskedquestionsExtensionsqualityguidelinesFAQAPIReferenceSamplesDevelopextensionsandthemesExtensiondevelopmentoverviewManifestfileformatArchitectureoverviewDeclarepermissionsDesigntheuserinterfaceDebuggingextensionsSamplesIndepth:coreconceptsMessagepassingContentscriptsManageeventswithserviceworkersMatchpatternsUsingpromisesCross-originisolationIndepth:securityCross-originXMLHttpRequestUsingevalinChromeextensionsIndepth:moretopicsOverridingChromesettingsExtendingDevToolsOAuth2:AuthenticateuserswithGoogleOverridingChromepagesRichnotificationsAPIModernizeyourextensionsMigratingfrombackgroundpagestoserviceworkersBestpracticesProtectuserprivacyDeclarepermissionsandwarnusersStaysecureAccessibility(a11y)LocalizationmessageformatsGiveusersoptionsDistributingyourextensionsExtensionhostingAlternativeextensioninstallationmethodsInstallingextensionsonLinuxTutorial:GoogleanalyticsManifestV2AboutManifestV2GettingstartedOverviewWhatareextensions?Whatarethemes?FrequentlyaskedquestionsDevelopextensionsandthemesExtensiondevelopmentoverviewManifestfileformatArchitectureoverviewDeclarepermissionsDesigntheuserinterfaceDebuggingextensionsSamplesIndepth:coreconceptsMessagepassingContentscriptsManageeventswithbackgroundscriptsMatchpatternsCross-originisolationIndepth:securityCross-originXMLHttpRequestUsingevalinChromeextensionsIndepth:moretopicsOverridingChromesettingsExtendingDevToolsOAuth2:AuthenticateuserswithGoogleOverridingChromepagesRichnotificationsAPIModernizeyourextensionsMigratetoevent-drivenbackgroundscriptsBestpracticesProtectuserprivacyDeclarepermissionsandwarnusersStaysecureAccessibility(a11y)LocalizationmessageformatsGiveusersoptionsDistributingyourextensionsChromeWebStoreAlternativeextensiondistributionoptionsInstallingextensionsonLinuxTutorial:GoogleanalyticsDocumentationExtensionsAPIReferenceExtensionsWelcomeWhat'snewinChromeextensionsGettingstartedIntroducingManifestV3WelcometoManifestV3ExtensionsplatformvisionOverviewofManifestV3MigratingtoManifestV3ManifestV3migrationchecklistManifestV2supporttimelineOverviewWhatareextensions?Whatarethemes?FrequentlyaskedquestionsExtensionsqualityguidelinesFAQAPIReferenceSamplesDevelopextensionsandthemesExtensiondevelopmentoverviewManifestfileformatArchitectureoverviewDeclarepermissionsDesigntheuserinterfaceDebuggingextensionsSamplesIndepth:coreconceptsMessagepassingContentscriptsManageeventswithserviceworkersMatchpatternsUsingpromisesCross-originisolationIndepth:securityCross-originXMLHttpRequestUsingevalinChromeextensionsIndepth:moretopicsOverridingChromesettingsExtendingDevToolsOAuth2:AuthenticateuserswithGoogleOverridingChromepagesRichnotificationsAPIModernizeyourextensionsMigratingfrombackgroundpagestoserviceworkersBestpracticesProtectuserprivacyDeclarepermissionsandwarnusersStaysecureAccessibility(a11y)LocalizationmessageformatsGiveusersoptionsDistributingyourextensionsExtensionhostingAlternativeextensioninstallationmethodsInstallingextensionsonLinuxTutorial:GoogleanalyticsManifestV2AboutManifestV2GettingstartedOverviewWhatareextensions?Whatarethemes?FrequentlyaskedquestionsDevelopextensionsandthemesExtensiondevelopmentoverviewManifestfileformatArchitectureoverviewDeclarepermissionsDesigntheuserinterfaceDebuggingextensionsSamplesIndepth:coreconceptsMessagepassingContentscriptsManageeventswithbackgroundscriptsMatchpatternsCross-originisolationIndepth:securityCross-originXMLHttpRequestUsingevalinChromeextensionsIndepth:moretopicsOverridingChromesettingsExtendingDevToolsOAuth2:AuthenticateuserswithGoogleOverridingChromepagesRichnotificationsAPIModernizeyourextensionsMigratetoevent-drivenbackgroundscriptsBestpracticesProtectuserprivacyDeclarepermissionsandwarnusersStaysecureAccessibility(a11y)LocalizationmessageformatsGiveusersoptionsDistributingyourextensionsChromeWebStoreAlternativeextensiondistributionoptionsInstallingextensionsonLinuxTutorial:Googleanalyticschrome.cookiesDescriptionUsethechrome.cookiesAPItoqueryandmodifycookies,andtobenotifiedwhentheychange.PermissionscookiesTableofcontentsManifestExamplesTypesCookieCookieDetailsCookieStoreOnChangedCauseSameSiteStatusMethodsgetgetAllgetAllCookieStoresremovesetEventsonChanged#ManifestTousethecookiesAPI,youmustdeclarethe"cookies"permissioninyourmanifest,alongwithhostpermissionsforanyhostswhosecookiesyouwanttoaccess.Forexample:{"name":"Myextension",..."host_permissions":["*://*.google.com"],"permissions":["cookies"],...}#ExamplesYoucanfindasimpleexampleofusingthecookiesAPIintheexamples/api/cookiesdirectory.Forotherexamplesandforhelpinviewingthesourcecode,seeSamples.SummaryTypesCookieCookieDetailsCookieStoreOnChangedCauseSameSiteStatusMethodsgetgetAllgetAllCookieStoresremovesetEventsonChangedTypesCookieRepresentsinformationaboutanHTTPcookie.PropertiesdomainstringThedomainofthecookie(e.g."www.google.com","example.com").expirationDatenumber optionalTheexpirationdateofthecookieasthenumberofsecondssincetheUNIXepoch.Notprovidedforsessioncookies.hostOnlybooleanTrueifthecookieisahost-onlycookie(i.e.arequest'shostmustexactlymatchthedomainofthecookie).httpOnlybooleanTrueifthecookieismarkedasHttpOnly(i.e.thecookieisinaccessibletoclient-sidescripts).namestringThenameofthecookie.pathstringThepathofthecookie.sameSiteSameSiteStatusChrome51+Thecookie'ssame-sitestatus(i.e.whetherthecookieissentwithcross-siterequests).securebooleanTrueifthecookieismarkedasSecure(i.e.itsscopeislimitedtosecurechannels,typicallyHTTPS).sessionbooleanTrueifthecookieisasessioncookie,asopposedtoapersistentcookiewithanexpirationdate.storeIdstringTheIDofthecookiestorecontainingthiscookie,asprovidedingetAllCookieStores().valuestringThevalueofthecookie.CookieDetailsChrome88+Detailstoidentifythecookie.PropertiesnamestringThenameofthecookietoaccess.storeIdstring optionalTheIDofthecookiestoreinwhichtolookforthecookie.Bydefault,thecurrentexecutioncontext'scookiestorewillbeused.urlstringTheURLwithwhichthecookietoaccessisassociated.ThisargumentmaybeafullURL,inwhichcaseanydatafollowingtheURLpath(e.g.thequerystring)issimplyignored.IfhostpermissionsforthisURLarenotspecifiedinthemanifestfile,theAPIcallwillfail.CookieStoreRepresentsacookiestoreinthebrowser.Anincognitomodewindow,forinstance,usesaseparatecookiestorefromanon-incognitowindow.PropertiesidstringTheuniqueidentifierforthecookiestore.tabIdsnumber[]Identifiersofallthebrowsertabsthatsharethiscookiestore.OnChangedCauseChrome44+Theunderlyingreasonbehindthecookie'schange.Ifacookiewasinserted,orremovedviaanexplicitcallto"chrome.cookies.remove","cause"willbe"explicit".Ifacookiewasautomaticallyremovedduetoexpiry,"cause"willbe"expired".Ifacookiewasremovedduetobeingoverwrittenwithanalready-expiredexpirationdate,"cause"willbesetto"expired_overwrite".Ifacookiewasautomaticallyremovedduetogarbagecollection,"cause"willbe"evicted".Ifacookiewasautomaticallyremovedduetoa"set"callthatoverwroteit,"cause"willbe"overwrite".Planyourresponseaccordingly.Type"evicted","expired","explicit","expired_overwrite",or"overwrite"SameSiteStatusChrome51+Acookie's'SameSite'state(https://tools.ietf.org/html/draft-west-first-party-cookies).'no_restriction'correspondstoacookiesetwith'SameSite=None','lax'to'SameSite=Lax',and'strict'to'SameSite=Strict'.'unspecified'correspondstoacookiesetwithouttheSameSiteattribute.Type"no_restriction","lax","strict",or"unspecified"Methodsgetchrome.cookies.get( details:CookieDetails, callback?:function,)PromiseRetrievesinformationaboutasinglecookie.IfmorethanonecookieofthesamenameexistsforthegivenURL,theonewiththelongestpathwillbereturned.Forcookieswiththesamepathlength,thecookiewiththeearliestcreationtimewillbereturned.ParametersdetailsCookieDetailscallbackfunction optionalThecallbackparameterlookslike:(cookie?:Cookie)=>voidcookieCookie optionalContainsdetailsaboutthecookie.Thisparameterisnullifnosuchcookiewasfound.ReturnsPromise
延伸文章資訊
- 1chrome.cookies
Use the chrome.cookies API to query and modify cookies, and to be notified when they change. Perm...
- 2在Chrome 中清除、啟用及管理Cookie - Android
清除所有Cookie · 在Android 手機或平板電腦上開啟Chrome 應用程式 Chrome 。 · 依序輕觸網址列右側的「更多」圖示 更多 下一步 · 依序輕觸[隱私權] 下一步 · ...
- 3如何在Google Chrome 裡刪除某一網站的Cookie 記錄 - 卓智 ...
如何在Google Chrome 裡刪除某一網站的Cookie 記錄 · 在Google Chrome 裡,去“Settings” · 搜索– “site settings” · 選擇“Cook...
- 4Chrome瀏覽器關閉後清除cookie和資料,外媒發現會對Google ...
正常的情況 ... 以Chrome來說,你可以在設定「隱私及安全性」的「Cookie 及其他網站資料」頁面進行設定。 ... 進入之後,打開「當你關閉Chrome時,清除Cookie ...
- 5Cookie Editor
A powerful and easy-to-use Cookie Editor. ... 如要下載到你的電腦,請登入Chrome 並啟用同步功能,或是傳送提醒給自己». (4265). 實用工具.