Conclusion
Christian Wenz
@chwenz
Agenda
Including Files
Secure Password Storage
State Management with Sessions
Include Files
PHP can include external PHP files
include
include_once
require
require_once
To include HTML files, use readfile()
Secure Password Storage
Do not store unencrypted passwords!
Do not use outdated hashing mechanisms like MD5 or SHA1!
PHP 5.5 offers the Password Hashing API
// hash a password
$p = password_hash('t0ps€cr3t', PASSWORD_DEFAULT);
/* $p ===
'$2y$10$O4crd4crz/jMbL6ByC2YhOxDHXACtXwr/cei.1tr.j
hWHTuCqn322‚ */
// verify a password
$ok = password_verify('t0ps€cr3t', $p);
State Management
Mechanism to store data across requests
Uses cookies with a unique ID to identify/remember users
// start session support
session_start();
// write to session
$_SESSION['key'] = 'value';
Summary
PHP can include PHP and HTML files (and other formats, too)
The Password Hashing API makes storing one-way encrypted
passwords easy
Sessions are used to store data on the server between requests
Happy PHP’ing!