SlideShare a Scribd company logo
(PHP) Sessions, Cookies, & Authentication Gerard Sychay #tek11 05/26/2011
Gerard Sychay. Zipscenemobile.com Cincy Coworks Introduction 0.
0. Introduction This is Henry
Introduction 0. baby
Introduction 0. Sessions Authentication Keep Me Logged In Security
Sessions 1. 1. initial request 2. create new  session ID 3. create session file named with ID 4. store ID in  ‘ PHPSESSID’ cookie
Sessions 1. 2. find file with name matching session ID 3. read session data from session file read session ID from  PHPSESSID cookie 4. respond using  session data
Sessions 1.
Authentication 2. Sessions… what are they good for?
// set a flag $_SESSION[‘authenticated’] = true; $_SESSION[‘loggedIn’] = true;  // save something  useful $_SESSION[‘userId’] = 123; $_SESSION[‘userName’] = ‘jsmith’; Authentication 2.
Authentication 2.
Authentication 2. “ You know that thing  that they have?”
Specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means “until the browser is closed.” Defaults to 0.   Authentication 2. session.cookie_lifetime
Specifies the number of seconds after which data will be seen as ‘garbage’ and potentially cleaned up.  Garbage collection may occur during session start. Defaults to 1440 seconds.   Authentication 2. session.gc_maxlifetime
Authentication 2. // 24h   session.cookie_lifetime = 86400;  // 24h   session.gc_maxlifetime = 86400;
Authentication 2.
Authentication 2. session.cookie_lifetime Absolute   expiration time   session.gc_maxlifetime Maximum  idle  time
Authentication 2. session.cookie_lifetime = 0;  // default session.gc_maxlifetime = 1440;  // default Example Henry: Never closes his browser Requests pages every 20 minutes or so. Stays logged in!
Authentication 2. session.cookie_lifetime = 0;  // default session.gc_maxlifetime = 1440;  // default Example Henry: Leaves his browser open  Takes a 30 min. snack break Session garbage collected – logged out!
Authentication 2. session.cookie_lifetime =  3600;  // 1 hr session.gc_maxlifetime = 1440;  // default Example Henry: Leaves his browser open  Takes a 30 min. snack break Session garbage collected – logged out!
Authentication 2. session.cookie_lifetime =  3600;  // 1 hr session.gc_maxlifetime =  3600;  // 1 hr Example Henry: Leaves his browser open  Takes a 45 min. snack break Works for 30 mins. Session cookie expires – logged out!
Oh yeah, what was I trying to do? Authentication 2.
Authentication 2.
Keep Me Logged In 3. do? What would
Keep Me Logged In 3. 1. initial login 4. store auth token in ‘my_auth’ cookie 3. store user’s unique auth token in DB 2. create new auth token for user
Keep Me Logged In 3. 1. read auth token  from ‘my_auth’cookie 2. lookup auth  token in DB 4. Store new session ID  and auth token in  cookies 3. if valid token, log user in
Keep Me Logged In 3.
What about security? Security 4.
Security 4.
Security 4. Firesheep
Security 4.
I CAN HAZ SSL? Security 4.
Re-authenticate! Security 4.
4. Security
@hellogerard http://straylightrun.net http://github.com/hellogerard/tek11 © 2011. Some rights reserved. Thanks! 5. Enjoy the wi-fi!

More Related Content

PPSX
Sessions and cookies
PPTX
Cookies and sessions
PPTX
Session and Cookies
PPT
PPT
PHP - Introduction to PHP Cookies and Sessions
PDF
Introduction to php web programming - sessions and cookies
PPTX
Cookie and session
Sessions and cookies
Cookies and sessions
Session and Cookies
PHP - Introduction to PHP Cookies and Sessions
Introduction to php web programming - sessions and cookies
Cookie and session

What's hot (20)

PPTX
PHP Cookies and Sessions
PPT
Php ssession - cookies -introduction
PPTX
Cookie & Session In ASP.NET
PPT
Cookies and sessions
PPT
Web Cookies
PPT
Php Sessoins N Cookies
PPTX
Sessions in php
PPTX
Cookies and Session
ODP
Session Management & Cookies In Php
PPTX
java Cookies
PPTX
PPT
Cookies and sessions
PPT
PHP - Getting good with cookies
PPSX
Php session
PPTX
Cookies: HTTP state management mechanism
PPTX
Internet Cookies
PDF
ASP.NET-Web Programming - Sessions and Cookies
PPT
Lecture8 php page control by okello erick
PPTX
Overview of Cookies in HTTP - Miran al Mehrab
PPT
16 cookies
PHP Cookies and Sessions
Php ssession - cookies -introduction
Cookie & Session In ASP.NET
Cookies and sessions
Web Cookies
Php Sessoins N Cookies
Sessions in php
Cookies and Session
Session Management & Cookies In Php
java Cookies
Cookies and sessions
PHP - Getting good with cookies
Php session
Cookies: HTTP state management mechanism
Internet Cookies
ASP.NET-Web Programming - Sessions and Cookies
Lecture8 php page control by okello erick
Overview of Cookies in HTTP - Miran al Mehrab
16 cookies
Ad

Viewers also liked (18)

PPT
Who's Using Your Software
PPTX
Cookies in PHP
PDF
Deliver Files With PHP
DOC
Php sessions
PPTX
Authentication and session v4
PPT
Php - Getting good with session
PDF
Merb Auth
KEY
Session 5 presentation
PPTX
Php Form
PPT
Chapter 07 php forms handling
PDF
PHP Files: An Introduction
PPTX
3 php forms
ODP
Form Processing In Php
PPT
Php forms
PPTX
Cookies Ppt
PPTX
Translation session
PPTX
Authentication scheme for session password using Images and color
PPTX
Translating Course and Session Objectives
Who's Using Your Software
Cookies in PHP
Deliver Files With PHP
Php sessions
Authentication and session v4
Php - Getting good with session
Merb Auth
Session 5 presentation
Php Form
Chapter 07 php forms handling
PHP Files: An Introduction
3 php forms
Form Processing In Php
Php forms
Cookies Ppt
Translation session
Authentication scheme for session password using Images and color
Translating Course and Session Objectives
Ad

Similar to PHP Cookies, Sessions and Authentication (15)

PPTX
FP512 Cookies sessions
KEY
Authentication
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
PPTX
Secure Code Warrior - Cookies and sessions
PPTX
Session tracking in servlets
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
PPT
Presentation on Internet Cookies
PDF
Lab Exercise: IBM Blockchain runs also on LinuxONE, see it in action!
TXT
H0 w decrypt
PPTX
The Dynamic Duo of Puppet and Vault tame SSL Certificates - Puppet Camps Cent...
PDF
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
PPTX
PHP COOKIES AND SESSIONS
PPTX
Hashitalks 2021 - How the Dynamic Duo of Vault and Puppet Tame SSL Certificates
PDF
Tales of modern day data breaches - a web security guide for developers
PPTX
lecture 12.pptx
FP512 Cookies sessions
Authentication
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Secure Code Warrior - Cookies and sessions
Session tracking in servlets
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Presentation on Internet Cookies
Lab Exercise: IBM Blockchain runs also on LinuxONE, see it in action!
H0 w decrypt
The Dynamic Duo of Puppet and Vault tame SSL Certificates - Puppet Camps Cent...
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
PHP COOKIES AND SESSIONS
Hashitalks 2021 - How the Dynamic Duo of Vault and Puppet Tame SSL Certificates
Tales of modern day data breaches - a web security guide for developers
lecture 12.pptx

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
Teaching material agriculture food technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Electronic commerce courselecture one. Pdf
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation theory and applications.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
KodekX | Application Modernization Development
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Cloud computing and distributed systems.
PPTX
Spectroscopy.pptx food analysis technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Spectral efficient network and resource selection model in 5G networks
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Network Security Unit 5.pdf for BCA BBA.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Teaching material agriculture food technology
MIND Revenue Release Quarter 2 2025 Press Release
Electronic commerce courselecture one. Pdf
Approach and Philosophy of On baking technology
Encapsulation theory and applications.pdf
Big Data Technologies - Introduction.pptx
cuic standard and advanced reporting.pdf
KodekX | Application Modernization Development
Building Integrated photovoltaic BIPV_UPV.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Per capita expenditure prediction using model stacking based on satellite ima...
Cloud computing and distributed systems.
Spectroscopy.pptx food analysis technology

PHP Cookies, Sessions and Authentication