SlideShare uma empresa Scribd logo
1 de 35
(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. ,[object Object],[object Object],[object Object],[object Object]
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 ,[object Object],[object Object],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!

Mais conteúdo relacionado

Mais procurados

Cookie & Session In ASP.NET
Cookie & Session In ASP.NETCookie & Session In ASP.NET
Cookie & Session In ASP.NET
ShingalaKrupa
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
UdaAs PaNchi
 
Web Cookies
Web CookiesWeb Cookies
Web Cookies
apwebco
 
Php Sessoins N Cookies
Php Sessoins N CookiesPhp Sessoins N Cookies
Php Sessoins N Cookies
mussawir20
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In Php
Harit Kothari
 
Cookies: HTTP state management mechanism
Cookies: HTTP state management mechanismCookies: HTTP state management mechanism
Cookies: HTTP state management mechanism
Jivan Nepali
 

Mais procurados (20)

PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and Sessions
 
Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introduction
 
Cookie & Session In ASP.NET
Cookie & Session In ASP.NETCookie & Session In ASP.NET
Cookie & Session In ASP.NET
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 
Web Cookies
Web CookiesWeb Cookies
Web Cookies
 
Php Sessoins N Cookies
Php Sessoins N CookiesPhp Sessoins N Cookies
Php Sessoins N Cookies
 
Sessions in php
Sessions in php Sessions in php
Sessions in php
 
Cookies and Session
Cookies and SessionCookies and Session
Cookies and Session
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In Php
 
java Cookies
java Cookiesjava Cookies
java Cookies
 
Session & Cookies
Session & CookiesSession & Cookies
Session & Cookies
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 
PHP - Getting good with cookies
PHP - Getting good with cookiesPHP - Getting good with cookies
PHP - Getting good with cookies
 
Php session
Php sessionPhp session
Php session
 
Cookies: HTTP state management mechanism
Cookies: HTTP state management mechanismCookies: HTTP state management mechanism
Cookies: HTTP state management mechanism
 
Internet Cookies
Internet CookiesInternet Cookies
Internet Cookies
 
ASP.NET-Web Programming - Sessions and Cookies
ASP.NET-Web Programming - Sessions and CookiesASP.NET-Web Programming - Sessions and Cookies
ASP.NET-Web Programming - Sessions and Cookies
 
Lecture8 php page control by okello erick
Lecture8 php page control by okello erickLecture8 php page control by okello erick
Lecture8 php page control by okello erick
 
Overview of Cookies in HTTP - Miran al Mehrab
Overview of Cookies in HTTP - Miran al MehrabOverview of Cookies in HTTP - Miran al Mehrab
Overview of Cookies in HTTP - Miran al Mehrab
 
16 cookies
16 cookies16 cookies
16 cookies
 

Destaque

Deliver Files With PHP
Deliver Files With PHPDeliver Files With PHP
Deliver Files With PHP
Thomas Weinert
 
Session 5 presentation
Session 5 presentation Session 5 presentation
Session 5 presentation
petersirr
 
Php Form
Php FormPhp Form
Php Form
lotlot
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In Php
Harit Kothari
 
Authentication scheme for session password using Images and color
Authentication scheme for session password using Images and colorAuthentication scheme for session password using Images and color
Authentication scheme for session password using Images and color
Nitesh Kumar
 

Destaque (18)

Who's Using Your Software
Who's Using Your SoftwareWho's Using Your Software
Who's Using Your Software
 
Cookies in PHP
Cookies in PHPCookies in PHP
Cookies in PHP
 
Deliver Files With PHP
Deliver Files With PHPDeliver Files With PHP
Deliver Files With PHP
 
Php sessions
Php sessionsPhp sessions
Php sessions
 
Authentication and session v4
Authentication and session v4Authentication and session v4
Authentication and session v4
 
Php - Getting good with session
Php - Getting good with sessionPhp - Getting good with session
Php - Getting good with session
 
Merb Auth
Merb AuthMerb Auth
Merb Auth
 
Session 5 presentation
Session 5 presentation Session 5 presentation
Session 5 presentation
 
Php Form
Php FormPhp Form
Php Form
 
Chapter 07 php forms handling
Chapter 07   php forms handlingChapter 07   php forms handling
Chapter 07 php forms handling
 
PHP Files: An Introduction
PHP Files: An IntroductionPHP Files: An Introduction
PHP Files: An Introduction
 
3 php forms
3 php forms3 php forms
3 php forms
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In Php
 
Php forms
Php formsPhp forms
Php forms
 
Cookies Ppt
Cookies PptCookies Ppt
Cookies Ppt
 
Translation session
Translation sessionTranslation session
Translation session
 
Authentication scheme for session password using Images and color
Authentication scheme for session password using Images and colorAuthentication scheme for session password using Images and color
Authentication scheme for session password using Images and color
 
Translating Course and Session Objectives
Translating Course and Session ObjectivesTranslating Course and Session Objectives
Translating Course and Session Objectives
 

Semelhante a PHP Cookies, Sessions and Authentication

Authentication
AuthenticationAuthentication
Authentication
soon
 
Hashitalks 2021 - How the Dynamic Duo of Vault and Puppet Tame SSL Certificates
Hashitalks 2021 - How the Dynamic Duo of Vault and Puppet Tame SSL CertificatesHashitalks 2021 - How the Dynamic Duo of Vault and Puppet Tame SSL Certificates
Hashitalks 2021 - How the Dynamic Duo of Vault and Puppet Tame SSL Certificates
Nick Maludy
 

Semelhante a PHP Cookies, Sessions and Authentication (14)

FP512 Cookies sessions
FP512 Cookies sessionsFP512 Cookies sessions
FP512 Cookies sessions
 
Authentication
AuthenticationAuthentication
Authentication
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.pptLecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
 
Secure Code Warrior - Cookies and sessions
Secure Code Warrior - Cookies and sessionsSecure Code Warrior - Cookies and sessions
Secure Code Warrior - Cookies and sessions
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
 
Presentation on Internet Cookies
Presentation on Internet CookiesPresentation on Internet Cookies
Presentation on Internet Cookies
 
Lab Exercise: IBM Blockchain runs also on LinuxONE, see it in action!
Lab Exercise: IBM Blockchain runs also on LinuxONE, see it in action!Lab Exercise: IBM Blockchain runs also on LinuxONE, see it in action!
Lab Exercise: IBM Blockchain runs also on LinuxONE, see it in action!
 
H0 w decrypt
H0 w decryptH0 w decrypt
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 - Puppet Camps Cent...The Dynamic Duo of Puppet and Vault tame SSL Certificates - Puppet Camps Cent...
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
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick MaludyThe Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
 
PHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSPHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONS
 
Hashitalks 2021 - How the Dynamic Duo of Vault and Puppet Tame SSL Certificates
Hashitalks 2021 - How the Dynamic Duo of Vault and Puppet Tame SSL CertificatesHashitalks 2021 - How the Dynamic Duo of Vault and Puppet Tame SSL Certificates
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
Tales of modern day data breaches - a web security guide for developersTales of modern day data breaches - a web security guide for developers
Tales of modern day data breaches - a web security guide for developers
 
lecture 12.pptx
lecture 12.pptxlecture 12.pptx
lecture 12.pptx
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

PHP Cookies, Sessions and Authentication