Geek Austin PHP Class - Session 3
-
Upload
jimbojsb -
Category
Technology
-
view
970 -
download
0
description
Transcript of Geek Austin PHP Class - Session 3
Beginning PHPSession #3
November 30, 2010
Josh Butts
Agenda
•Application organization
•Superglobals
•Forms, GET and POST
•Sessions
•Basic Dates & Times
Superglobals
•Available in every scope, no matter what
•Automatically set by PHP
•Arrays
•#1 attack vector
$_GET
•Associative array corresponding to the query string
•Use this for READ ONLY data
$_POST
•Associative array that corresponds to form POSTs
•Use this when you will be modifying something on the server
•Array keys correspond to HTML input names
$_POST
$_SERVER
•Contains environment information
•Contains information about the HTTP request used to access this page
Sessions
•Keep track of info about your user
•Each user gets an ID and a cookie
•Actual session data is stored on the server
•Low security but easy
Using Sessions
•Call session_start()
•Use $_SESSION superglobal to get and set data
•Sessions expire when the browser is closed (you can configure this)
Session Demo
Dates & Times•Dates & times are relative to the
timezone of your server
•time() - Unix Timestamp
•date() - format a date string
•mktime() - get a specific unix timestamp
•strtotime() - convert an english-ish string to a timestamp
extract()
•Registers all the keys in an array as variables
•Use extreme with caution
Let’s buildsomething real