--- title: cookies slug: Mozilla/Add-ons/WebExtensions/API/cookies tags: - API - Add-ons - Cookies - Extensions - Interface - NeedsTranslation - Non-standard - Reference - TopicStub - WebExtensions translation_of: Mozilla/Add-ons/WebExtensions/API/cookies ---
{{AddonSidebar}}

Позволяет  WebExtensions получить и установить куки ,а также сообщить об их изменении.

Для использования этого API,вам нужно предоставить доступ  API permission в вашем файле manifest.json,а также  host permissions для тех сайтов чьи куки вам нужны для доступа.Смотрите cookie Permissions.

Types

{{WebExtAPIRef("cookies.Cookie")}}
Предоставляет информацию о HTTP cookie
{{WebExtAPIRef("cookies.CookieStore")}}
Represents a cookie store in the browser.
{{WebExtAPIRef("cookies.OnChangedCause")}}
Represents the reason a cookie changed.

Methods

{{WebExtAPIRef("cookies.get()")}}
Запрашивает информацию об одном кукис.
{{WebExtAPIRef("cookies.getAll()")}}
Выдаёт все кукис которые подходят установленному фильтру.
{{WebExtAPIRef("cookies.set()")}}
Устанавливает кукис с заданной информацией;в том случае если подобный кукис был информация будет перезаписана.
{{WebExtAPIRef("cookies.remove()")}}
Удаляет кукис по имени.
{{WebExtAPIRef("cookies.getAllCookieStores()")}}
Список всех существующих куки

Event handlers

{{WebExtAPIRef("cookies.onChanged")}}
Происходит когда кукис задаётся или меняется.

Permissions

In order to use this API, an add-on must specify the "cookies" API permission in its manifest, along with host permissions for any sites for which it wishes to access cookies. The add-on may read or write any cookies which could be read or written by a URL matching the host permissions. For example:

http://*.example.com/

An add-on with this host permission may:

It may not:

http://www.example.com/

An add-on with this host permission may:

It may not:

*://*.example.com/

An add-on with this host permission may:

Browser compatibility

{{Compat("webextensions.api.cookies")}}

Edge incompatibilities

Promises are not supported in Edge. Use callbacks instead.

{{WebExtExamples("h2")}}

Acknowledgements

This API is based on Chromium's chrome.cookies API. This documentation is derived from cookies.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.