Data, network and security

The data layer and the network, then the attacks a public page has to survive: PDO transactions and fetch modes, cURL, XML and CSV, hardened sessions, password hashing, XSS and CSRF, SQL injection, and mail.

11.1 PDO transactions group writes in a transaction, commit, and roll back on failure Open 11.2 PDO fetch modes fetch rows as arrays, as objects, and as a single column Open 11.3 cURL requests a cURL handle, its options, and the error check after the call Open 11.4 Parallel cURL many URLs at once with a cURL multi handle and a run loop Open 11.5 XML with SimpleXML and DOM SimpleXML, XPath queries, and safe documents from DOMDocument Open 11.6 CSV files fgetcsv and fputcsv, streaming a large file row by row Open 11.7 Harden sessions safe cookie params, id rotation, and simple theft detection Open 11.8 Password hashing password_hash, password_verify, and an upgrade that keeps old hashes Open 11.9 XSS and CSRF output escaping against XSS, tokens and SameSite cookies against CSRF Open 11.10 SQL injection defense prepared statements, safe LIKE patterns, and integer LIMIT values Open 11.11 Send email simple mail, safe headers, and a queue instead of a blocking request Open

Lessons