Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
知っててうれしい HTTP Cookie について
Search
greendrop
December 12, 2024
Technology
380
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
知っててうれしい HTTP Cookie について
greendrop
December 12, 2024
Transcript
13 slides
知っててうれしい 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
More Decks by greendrop
See All by greendrop
gh skill コマンドで AI エージェントのスキルを一元管理・自動配布する
greendrop
0
60
GitHub Actions の設定を少しよくする
greendrop
0
56
リンクからモバイルアプリを起動する技術
greendrop
0
51
知っててうれしい SQL について
greendrop
0
370
知っててうれしい HTTP Cookie を使ったセッション管理について
greendrop
1
370
知っててうれしいリレーショナルデータベースについて
greendrop
0
320
スマホアプリエンジニアでない方へ向けた、スマホアプリ開発に関連するトピック
greendrop
0
310
知っててうれしい HTTP について
greendrop
0
400
知っててうれしい HTTP キャッシュについて
greendrop
0
430
Other Decks in Technology
See All in Technology
Go でトランザクション、どう書いてますか?
knwoop
1
430
20261119_AgentCore
takuyay0ne
1
180
人の努力に頼らないセキュリティをエンジニアリングする在り方 / An approach to engineering security that does not rely on human effort
carta_engineering
0
240
MCPでネットワーク障害調査を自動化する前に直すべき3つのこと
yama3133
1
650
さようならSSH鍵、こんにちはゼロトラスト ― AIフレンドリーで快適な自宅鯖SSH
atalie2m
14
7.4k
統制されたID・権限をどう利用するか : DPoP/FAPIによるAPIセキュリティ強化
oidfj
2
280
セキュリティチームは どのコンテナイメージの脆弱性対応を優先すべきか 〜CISA新指針とSCCで作る脆弱性トリアージ〜
swdtkuy
0
280
Terraform 0 to 100:100個以上のリポジトリを常に最新にし続けるための自動化
sue445
3
1.4k
OpenTelemetryで変わった 新時代のCloudWatchメトリクス監視
tsukuboshi
0
490
Web Performance Is a Journey [PerfNow 2026]
tammyeverts
2
120
その修正で本当に速くなったのか? k6とOpenTelemetryで確かめる性能改善 / Performance review with k6 and OpenTelemetry
ymotongpoo
3
420
gradle-best-practices 使ってみた
mikanichinose
0
220
Featured
See All Featured
The SEO identity crisis: Don't let AI make you average
varn
0
630
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
530
Designing Powerful Visuals for Engaging Learning
tmiket
1
660
Mobile First: as difficult as doing things right
swwweet
225
10k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
6
960
Automating Front-end Workflow
addyosmani
1370
210k
From π to Pie charts
rasagy
1
460
How to train your dragon (web standard)
notwaldorf
96
6.9k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
570
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Practical Orchestrator
shlominoach
192
12k