academia.sh
/
PHP
/
PHP on the Web: State, Data and Security
Course
Intermediate
PHP on the Web: State, Data and Security
Published
October 15, 2026
·
Updated
October 21, 2026
By the end of this course
Measures whether a result belongs to the server, the environment, the client or a third party by applying a single deviation from each outside party
Builds session- and cookie-based state safely with signatures, session identifier regeneration and cookie attributes
Accesses the database through prepared statements and parameterized queries, and protects data integrity with transactions and migrations
Applies input validation, output escaping, anti-forgery tokens and password hashing as defenses against common web vulnerabilities
Shows with a before/after run that a defense moves a result from an outside party to the server
01
Cookies, sessions, configuration and environment variables — the mechanisms that decide which part of the state carried between requests lives on the client, which on the server and which in the deployment environment.
01
Cookies
How the cookie carries state on the client between requests, through the Set-Cookie header and its signed form; the four parties that classify who can change a result, and the ten-result measurement.
02
Sessions
The session mechanism that keeps state on the server: the ID in the session cookie, $_SESSION, session_regenerate_id(true), and the limit set by the party that carries the ID.
03
Configuration and Environment Variables
Separating deployment-dependent values such as the connection name and the key from the code and reading them from environment variables; the explicit error on a missing variable and the cost of a value fixed in code.
02
The database access layer, transactions, migration management, the queries behind object–relational mapping, data formats and the HTTP client — at every point where the application reads and writes data, whether the result is decided by the code, the environment or an outside party.
01
The Database Access Layer
Sets up a PDO connection, the error mode, prepared statements, named and positional placeholders and fetch modes; when a connection option comes from the environment, measures who can change the type of the returned value.
02
Transactions
Runs a transfer between two accounts with and without a transaction; when the second write fails, measures who can change the balance total, and shows what a transaction without a rollback call does not protect.
03
Migration Management
Builds migration files, a migration log table, ordered application and rollback in a small mechanism; measures that the database state decides how many migrations are applied in a run, while the code decides the schema version.
04
Queries Behind Object–Relational Mapping
Counts the queries sent while a list is printed with a counter; measures that the query count grows with the rows in lazy loading, stays at two in eager loading, and that the query text can still change with the data sent.
05
Data Formats
Parses JSON, XML and CSV text from a partner; measures who can change the result when the partner writes the same field differently, and shows whose choice the number notation in our own response is.
06
The HTTP Client
Builds an HTTP client from request and response objects, a transport closure, a timeout exception, retry and a fallback value; measures how the price reported by the service and these defenses change who owns the result.
03
Input validation and sanitization, SQL injection, cross-site scripting, request forgery, password storage and authentication flows — each as a defense that takes a result out of the hands of the client or a third party and moves it to the server.
01
Input Validation and Sanitization
Narrowing a client input to the valid set with filter_var(), and measuring that validation and sanitization are separate steps and that validation does not take the power to change the value away from the client.
02
Preventing SQL Injection
Measuring the parameterized query that separates the query text from the client's value: the same query changes with the value under concatenation, does not change with a prepared statement, and binding does not work everywhere.
03
Preventing Cross-Site Scripting
Measuring how escaping narrows the result when text from a user is printed onto a page, escaping by context and double escaping; escaping does not change the owner.
04
Request Forgery Protection
Telling apart whether a request was made by the user's own application or by another site with a request forgery token, the measured effect of the token, and the limit of the SameSite cookie attribute.
05
Password Storage
Measuring that a password is stored as a hash, that a different salt gives a different hash for the same password, the cost parameter, and rehashing at login; the default cost is in the environment's hands.
06
Authentication Flows
Measuring the identity of a request in the session-based and the bearer-token flow, seeing what a signature protects and what it does not, and gathering the fifteen lessons of the course into one table.
Final exam
PHP on the Web: State, Data and Security — Final Exam
In preparation
This course's question bank is not complete yet. The exam opens here automatically once enough questions are added.
Start the exam
↑↓
↵
Esc
navigate · open · close