拡張機能に cookie の取得と設定と、変更された時の通知を可能にします。
この API を使用するには、manifest.json ファイルで "cookies" の API パーミッション があることと、同様にアクセスする cookie を持つ host パーミッション も必要になります。cookie パーミッションを見てください。
型
cookies.Cookie
- HTTP cookieの情報を表す。
cookies.CookieStore
- ブラウザーの cookie store を表す。
cookies.OnChangedCause
- cookie の変更理由を表す。
メソッド
cookies.get()
- 1つの cookie の情報を取得する。
cookies.getAll()
- 与えられたフィルターにマッチするすべての cookies を取得する。
cookies.set()
- 与えられた cookie データ を cookie に設定する; おなじ cookies が存在すれば上書きする。
cookies.remove()
- 指定した名前の cookie を削除する。
cookies.getAllCookieStores()
- すべての cookie stores を一覧する。
イベントハンドラー
cookies.onChanged
- cookie が設定、削除された時に発火する。
パーミッション
この API を使うには、アドオンは manifest で "cookies" の API パーミッション を指定せねばならず、同様に cookie がアクセスするあらゆるサイトの host パーミッションも要ります。アドオンは host パーミッションにマッチするURLから読み書きされる cookie を読み書きできます。例えば:
http://*.example.com/
-
この host パーミッションを持つアドオンは下記ができます:
www.example.com
のあらゆるパスの、非セキュア型 cookie を読む- セキュア/非セキュア問わず、
www.example.com
のあらゆるパスの cookie に書き込む
下記はできません:
www.example.com
のセキュア型cookie を読む
http://www.example.com/
-
この host パーミッションを持つアドオンは下記ができます:
www.example.com
のあらゆるパスの、非セキュア型cookie を読む.example.com
のあらゆるパスの、非セキュア型cookie を読む- セキュア/非セキュア問わず、
www.example.com
のあらゆるパスの cookie に書き込む - セキュア/非セキュア問わず、
.example.com
のあらゆるパスの cookie に書き込む
下記はできません:
foo.example.com
の cookie の読み書きfoo.www.example.com
の cookie の読み書き
*://*.example.com/
-
この host パーミッションを持つアドオンは下記ができます:
- セキュア/非セキュア問わず、
www.example.com
のあらゆるパスの cookie の読み書き
- セキュア/非セキュア問わず、
ブラウザ実装状況
デスクトップ | モバイル | ||||
---|---|---|---|---|---|
Cookie | Chrome 完全対応 あり | Edge 完全対応 14 | Firefox 完全対応 45 | Opera 完全対応 あり | Firefox Android 完全対応 48 |
CookieStore | Chrome 完全対応 あり | Edge 完全対応 14 | Firefox 完全対応 45 | Opera 完全対応 あり | Firefox Android 完全対応 48 |
OnChangedCause | Chrome 完全対応 あり | Edge 未対応 なし | Firefox 完全対応 45 | Opera 完全対応 あり | Firefox Android 完全対応 48 |
get | Chrome 完全対応 あり | Edge 完全対応 14 | Firefox
完全対応
45
| Opera 完全対応 あり | Firefox Android 完全対応 48 |
getAll | Chrome 完全対応 あり | Edge
完全対応
14
| Firefox
完全対応
45
| Opera 完全対応 あり | Firefox Android 完全対応 48 |
getAllCookieStores | Chrome 完全対応 あり | Edge
完全対応
14
| Firefox
完全対応
45
| Opera 完全対応 あり | Firefox Android 完全対応 48 |
onChanged | Chrome 完全対応 あり | Edge 未対応 なし | Firefox 完全対応 45 | Opera 完全対応 あり | Firefox Android 完全対応 48 |
remove | Chrome 完全対応 あり | Edge 完全対応 14 | Firefox
完全対応
45
| Opera 完全対応 あり | Firefox Android
完全対応
48
|
set | Chrome 完全対応 あり | Edge 完全対応 14 | Firefox
完全対応
45
| Opera 完全対応 あり | Firefox Android
完全対応
48
|
凡例
- 完全対応
- 完全対応
- 未対応
- 未対応
- 実装ノートを参照してください。
- 実装ノートを参照してください。
Example extensions
この API は Chromium の chrome.cookies
API に基づいています。また、このドキュメントは cookies.json
における Chromium のコードに基づいています。
Microsoft Edge での実装状況は Microsoft Corporation から提供されたものであり、ここでは Creative Commons Attribution 3.0 United States License に従っています。
// Copyright 2015 The Chromium Authors. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.