Mapa mental
Cookies, Sessions & Authentication

Conteúdo do mapa
Cookies, Sessions & Authentication
HTTP Response and Request
- Request
- $_GET
- $_POST
- $_REQUEST
- header($str)
- Response
- get_headers($url)
- http_response_code()
- HTTP Status codes
- Let client know what status its request is
- HTTP is stateless
- Treat every interaction as a new request
- No info passed from one to another
- Cookies and sessions used to pass info between pages
- No info passed from one to another
- Treat every interaction as a new request
- Request
Cookies
- Cookie
- Small pieces of info about user store on the user's computer
- Sent by server to a browser, then sent back on future page requests
- Consists of single name/value pair
- Session cookie
- Default type, temporarily stored only in browser's memory
- Persistent cookie
- Stored in a file on the browser's computer
- Small pieces of info about user store on the user's computer
- When are they useful?
- Authentication, user tracking and maintaining user preferences, shopping carts
- Setting cookies
- setcookie(name[,value, expires, path, domain])
- Path
- Availability of a cookie to other web pages on a server
- Domain
- Sharing cookies across servers in the same domain
- Path
- Retrieving cookie info
- Automatically assigned $_COOKIE super global
- isset() checks if cookie is set
- e.g. if(isset($_COOKIE["user"]))...
- isset() checks if cookie is set
- Automatically assigned $_COOKIE super global
- setcookie(name[,value, expires, path, domain])
- Limitations
- Users can easily disable cookies
- Easily deleted
- PHP sets limit size on cookies
- Must be set before you can send HTTP headers (request/response)
- Less secure than sessions
- Cookie
Sessions
- A session is a sequence of HTTP requests and responses between a browser and a server
- Allow you to keep track of your users even when clients disable cookies
- Server stores client's IP and local session data
- Sends session ID back - PHPSESSID
- Sent back on future requests
- If users have cookies off, session ID passed as query string from page to page
- Sends session ID back - PHPSESSID
- PHP Session Variables
- session_start() script to start session
- $_SESSION global array
- Consists of an ID, and data stored on the server (unlike the browser with cookies)
- A session is a sequence of HTTP requests and responses between a browser and a server
Authentication
- Tell a web application who you are
- Form-based authentication
- Using standard HTML form fields, pass username, password etc.
- Creates a session
- Using standard HTML form fields, pass username, password etc.
- Token-based authentication
- Request to a server is accompanied by a signed token
- Verify authenticity, only then respond
- Request to a server is accompanied by a signed token
- Form-based authentication
- Tell a web application who you are
Imagens e arquivos do mapa
Informações
- Descrição
- Computer Science Mapa Mental sobre Cookies, Sessions & Authentication, criado por Alex Bernini em 15-05-2019.
- Criado por
- Alex Bernini
- Visualizações
- 0
- Avaliação

