10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Safari上から cookie の追加・編集を行う

Last updated at Posted at 2019-07-04

Safari上から、cookie をいろいろ追加・編集・削除したいというケースがあって

Chrome なら、拡張機能 "Edit This Cookie" あたりを使えばOKという話ですが、Safari でそれっぽい機能が見つからずでして

js-cookie を読み込ませて使う

JavaScript の cookie操作の定番ライブラリ "js-cookie" を、Safari に読み込ませて使えば対応できました

Safari の JavaScriptコンソールから

  1. js-cookie を読み込ませる
script = document.createElement('script'); script.src = 'https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js'; document.getElementsByTagName('head')[0].appendChild(script)
  1. そのままコンソールで cookie 設定
Cookies.set('foo', 'bar');

こんな感じで操作可能に

cookie の参照は Cookies.get() でもできますが、コンソール上部の「ストレージ」タブからも確認できます。(削除もここからできた)

10
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?