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
セッションとCookieをおさらい / session and cookie
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Yutaro Shimoda
October 22, 2021
Programming
0
390
セッションとCookieをおさらい / session and cookie
エンジニア2年目にしてセッションとCookieについておさらいしました。
なんか、フワッとした理解しているところもあったので良い復習になりました!!
Yutaro Shimoda
October 22, 2021
Tweet
Share
More Decks by Yutaro Shimoda
See All by Yutaro Shimoda
AI時代のPMに求められるのは 「Ops」と「Enablement」
shimotaroo
1
960
エンジニアの次のキャリアに プロダクトマネージャーという選択
shimotaroo
2
710
SNSは最強
shimotaroo
3
720
それ、プロダクトに機能追加しなくてもよくないっすか?
shimotaroo
0
400
イシューからはじめよう
shimotaroo
0
560
マーケ・セールス担当者の話を理解したいいいいい!!!
shimotaroo
0
1.3k
自分のペースで頑張ればいんじゃない?というお話
shimotaroo
0
1.9k
つながる勉強会立ち上げからの1年間を振り返る/tsunagaru-kobe-2021
shimotaroo
0
290
【ハンズオン】PHPUnitでのテストコード実装超入門/PHP-Hands-On
shimotaroo
0
6.2k
Other Decks in Programming
See All in Programming
GoのDB アクセスにおける 「型安全」と「柔軟性」の両立 - Bob という選択肢
tak848
0
110
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.3k
Everything Claude Code OSS詳細 — 5層構造の中身と導入方法
targe
0
120
Rで始めるML・LLM活用入門
wakamatsu_takumu
0
180
Fundamentals of Software Engineering In the Age of AI
therealdanvega
1
260
20260313 - Grafana & Friends Taipei #1 - Kubernetes v1.36 的開發雜記:那些困在 Alpha 加護病房太久的 Metrics
tico88612
0
200
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
250
OTP を自動で入力する裏技
megabitsenmzq
0
110
AI時代のシステム設計:ドメインモデルで変更しやすさを守る設計戦略
masuda220
PRO
5
1k
コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions
handlename
0
200
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
270
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
160
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Paper Plane (Part 1)
katiecoart
PRO
0
5.6k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
180
Statistics for Hackers
jakevdp
799
230k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
190
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
140
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
180
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
640
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
110
Technical Leadership for Architectural Decision Making
baasie
3
290
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
250
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
260
Transcript
セッションとCookieをおさらい 2021/8/28(土)
なぜ使うのか? ステートレスなHTTPをステートフルに使うため 客「ハンバーガーセットをお願いします。」 店員「ハンバーガーセットですね。ドリンクは何にしますか?」 客「ファンタでお願いします」 店員「ファンタですね。サイズは何にしますか?」 客「Mでお願いします。」 店員「M?は?何がですか?」 これがステートフル
Cookie(クッキー)とは • クライアント(ブラウザ)に保存されたデータ • サーバーからのHTTPレスポンスヘッダー(Set-Cookie)を用いてWebブラウザに送 られる • サーバーにアクセスするたびに自動送信される • 「クッキー名=値」の形(1つのクッキーは4KBまで)
• ブラウザによって保持できる数が異なる
セッション(Session)とは • 一連の処理の始まりから終わりまでを表す概念 ◦ ログイン〜ログアウト ◦ HTTP通信の接続を確立〜遮断 • Cookieを利用することでセッション(一連の処理)を実現できる=ステートレスをス テートフルにできる
• 「ログインしている」という情報のことをクライアントのアプリケーション状態といい、 別名でセッション状態とも言う。
使用されるケース ユーザーの識別(認証)が必要なアプリケーション • ECサイト • 転職サイト • SNS など
Cookieを使用したセッション管理の仕組み① クライアント ログイン Cookieを保存するよう指示 ・セッションID発行 ・セッション情報保存 セッションファイル サーバー Cookieをブラウザに保存 Cookie
名前:sessionid 値:9reifwjgkrnrqfuvoijqfi sessionid: 9reifwjgkrnrqfuvoijqfi user_id: 1 sessionid: 9reifwjgkrnrqfuvoijqfi
Cookieを使用したセッション管理の仕組み② クライアント 認証が必要なリクエスト サーバー sessionid: 9reifwjgkrnrqfuvoijqfi user_id: 1 Cookieも送る sessionid:
9reifwjgkrnrqfuvoijqfi 9reifwjgkrnrqfuvoijqfi CookieからセッションIDを取り出す セッションファイルと照合 user_id=1のユーザー を識別できる ユーザーがログインしているという状態を維持できる
最後におさらい • Cookieは、クライアント(ブラウザ)に保存されたデータ • セッションは、一連の処理の始まりから終わりまでを表す概念 • Cookieとセッションを組み合わせて使うことでステートレスなHTTPをステートフルに することができる • セッションとCookieによるセッション管理はユーザーの識別(認証)が必要なアプリ
ケーションで使用される
ご静聴ありがとうございました!