Sessions
Sessions
HTTP is Stateless
Some form of user identification must be passed on every request.
HTTP Auth - $_SERVER['PHP_AUTH_USER'] $_SERVER['PHP_AUTH_PW']
Unique token passed via Cookies or propagated in the URL
PHP Sessions - preserve data across subsequent requests
Cookie or URL token (php.ini - session.use_trans_sid)
Cookie: mysite_session=9610699d7cd544c66e0e1fc41358bc6f
session_start() or php.ini - session.auto_start = 1
Superglobal $_SESSION
Default: PHPSESSID -- php.ini session.name
session_name
(
'mysite_session'
)
;
session_start
(
)
;
$
_SESSION
[
'myvar'
]
=
'Some Value'
;