EditThisCookieでクッキーが追加できない

2022.01.18

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

こんにちは、CX事業本部 IoT事業部の若槻です。

今回は、EditThisCookieでクッキーが追加できない事象に遭遇したので対処方法を確認してみました。

EditThisCookieでクッキーが追加できない

EditThisCookieは、保存されているクッキー(HTTP Cookie)の閲覧や手動での編集、追加ができるブラウザ拡張機能です。

私はクッキーを利用するアプリケーションのデバッグの際に、EditThisCookieのChrome拡張版をよく使用しています。

このEditThisCookieでデバッグのためにクッキーを手動追加しようとしました。

クッキーを追加したい場合は、WebサイトでEditThisCookieを開き、[+]をクリックします。

クッキーの名前と値を指定して、チェックマークをクリックします。

しかし一覧は[Cookieはありません]のままで、追加ができていないようです。

解決

クッキーを追加する際に[安全(Secure)]にチェックを入れる必要がありました。

チェックを入れて追加すると、ちゃんと追加できました。

どういうことなのか

この「安全(Secure)」にチェックを入れることにより、クッキーにSecure属性をtrueとすることができます。Secure属性がtrueのクッキーはブラウザからの送信時に必ずHTTPS暗号化されるため、意図しない第三者からアクセスされないようにすることができます。

You can ensure that cookies are sent securely and aren't accessed by unintended parties or scripts in one of two ways: with the Secure attribute and the HttpOnly attribute.

A cookie with the Secure attribute is only sent to the server with an encrypted request over the HTTPS protocol. It's never sent with unsecured HTTP (except on localhost), which means man-in-the-middle attackers can't access it easily. Insecure sites (with http: in the URL) can't set cookies with the Secure attribute. However, don't assume that Secure prevents all access to sensitive information in cookies. For example, someone with access to the client's hard disk (or JavaScript if the HttpOnly attribute isn't set) can read and modify the information.

しかしSecure属性がfalseの場合にどうしてクッキーが追加できないのかは正直なところ分かりませんでしたが、EditThisCookieの何らかの動作によるものだと思われます。私の方で精査はできていませんが、ソースコードがGitHubに公開されているので興味のある方は調べてみてください。

以上