Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
知っててうれしい HTTP Cookie について
Search
greendrop
December 12, 2024
Technology
310
0
Share
知っててうれしい HTTP Cookie について
greendrop
December 12, 2024
More Decks by greendrop
See All by greendrop
gh skill コマンドで AI エージェントのスキルを一元管理・自動配布する
greendrop
0
33
GitHub Actions の設定を少しよくする
greendrop
0
41
リンクからモバイルアプリを起動する技術
greendrop
0
24
知っててうれしい SQL について
greendrop
0
320
知っててうれしい HTTP Cookie を使ったセッション管理について
greendrop
1
310
知っててうれしいリレーショナルデータベースについて
greendrop
0
270
スマホアプリエンジニアでない方へ向けた、スマホアプリ開発に関連するトピック
greendrop
0
240
知っててうれしい HTTP について
greendrop
0
330
知っててうれしい HTTP キャッシュについて
greendrop
0
370
Other Decks in Technology
See All in Technology
Chart.js が簡単に使えるようになっていたので OGP 画像生成に使った話
kamekyame
0
140
運用を見据えたAIエージェント設計実践
amacbee
0
2.3k
関西に縁あるMicrosoft MVPsが語るCopilotの未来
kasada
0
1k
TROCCOで始めるクラウドコストを民主化するためのFinOps
tk3fftk
3
550
美味しいスイスチーズを作ろう🧀🐭
taigamikami
1
230
コードレビューを制するチームがソフトウェアデリバリーのフローを制す / Beyond Code Review: Distributing Its Responsibilities Across the SDLC
mtx2s
3
840
Oracle Cloud Infrastructure IaaS 新機能アップデート 2026/3 - 2026/5
oracle4engineer
PRO
1
150
先取りMaven4 ~16年ぶりのメジャーアップデート、その進化とは?~
ogiwarat
0
140
AI駆動開発が変える、大規模開発の前提 ーHuman in the Loop から Human on the Loop へ / AIE2026
visional_engineering_and_design
2
2k
React、まだ楽しくて草
uhyo
7
3.9k
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
4
1.8k
エンジニアは生成AIと どのように向き合うべきか? ことばの意味という観点から
verypluming
3
340
Featured
See All Featured
The agentic SEO stack - context over prompts
schlessera
0
790
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.8k
Between Models and Reality
mayunak
4
320
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
300
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
380
Documentation Writing (for coders)
carmenintech
77
5.4k
Designing for humans not robots
tammielis
254
26k
WCS-LA-2024
lcolladotor
0
610
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Transcript
知っててうれしい HTTP Cookie について 2024/12/12 1
目次 HTTP Cookie とは Cookie の作成 Cookie の更新 Cookie の削除
Cookie の容量 Cookie のセキュリティ まとめ 2
HTTP Cookie とは HTTP Cookie は、Web サーバーからクライアントに送信される情報 を保存する仕組みです。 Web サーバーは、クライアントに対して
Cookie を送信し、クライア ントは Cookie を保存して、次回以降の通信で Cookie を送信します。 HTTP Cookie とは 3
Cookie の作成 Cookie は、レスポンスヘッダーの Set-Cookie で作成します。 HTTP/1.1 200 OK Content-Type:
text/html Set-Cookie: name1=value1 Set-Cookie: name2=value2 Cookie の作成 4
Cookie の更新 Cookie を保持している状態でリクエストを送信し、レスポンスヘッダーの Set-Cookie で Cookie を更新します。 リクエスト GET
/index.html HTTP/1.1 Host: example.com Cookie: name1=value1; name2=value2 レスポンス HTTP/1.1 200 OK Content-Type: text/html Set-Cookie: name1=value3 Set-Cookie: name2=value4 Cookie の更新 5
Cookie の削除 Cookie を削除するには、Cookie の有効期限を過去の日時に設定しま す。 HTTP/1.1 200 OK Content-Type:
text/html Set-Cookie: name1=; expires=Thu, 01 Jan 1970 00:00:00 GMT Cookie の削除 6
Cookie の容量 Cookie の容量は、1 Cookie あたり 4 KB までとされています。 Cookie
は、リクエストに含まれるため、Cookie の容量が大きいと通 信量が増加します。 Cookie の容量 7
Cookie のセキュリティ Cookie は、クライアントとサーバーの通信において平文で送信される ため、Cookie にはセキュリティ上のリスクがあります。 Cookie の設定を適切に行い、セキュリティを確保する必要がありま す。 Cookie
のセキュリティ 8
Cookie 送信先の設定 Cookie は、ドメイン、パスで送信先を設定することで、対象外のドメ イン・パスに Cookie が送信されるのを防ぐことができます。 domain でドメインを指定 path
でパスを指定 HTTP/1.1 200 OK Content-Type: text/html Set-Cookie: name=value; domain=example.com; path=/ Cookie のセキュリティ - 送信先の制限 9
Cookie Secure 属性, HttpOnly 属性 Cookie には、Secure 属性、HttpOnly 属性を設定することで、意図し ない第三者やスクリプトからアクセスされないようにできます。
Secure 属性: HTTPS 通信の場合のみ Cookie を送信 HttpOnly 属性: JavaScript から Cookie にアクセスできない HTTP/1.1 200 OK Content-Type: text/html Set-Cookie: name=value; Secure; HttpOnly Cookie のセキュリティ - Secure 属性, HttpOnly 属性 10
Cookie SameSite 属性 Cookie には、SameSite 属性を設定することで、サードパーティ Cookie の 送信を制御できます。 Strict
: 発行元のサイトにのみ Cookie を送信 Lax : 発行元のサイトにのみ Cookie を送信( 別サイトから移動時も含む) None : サードパーティ Cookie の送信を許可 HTTP/1.1 200 OK Content-Type: text/html Set-Cookie: name=value; SameSite=Strict Cookie のセキュリティ - SameSite 属性 11
まとめ HTTP Cookie は、Web サーバーからクライアントに送信される情 報を保存する仕組み Cookie は、レスポンスヘッダーの Set-Cookie で作成・更新・削除
Cookie は、リクエストに含まれるため、Cookie の容量が大きいと 通信量が増加 Cookie は、セキュリティ上のリスクがあるため、適切な設定が必 要 まとめ 12
ご清聴ありがとうございました。 13