PHP

SIMPLE SESSIONS IN PHP

(quick beginner's guide)

START SESSION session_start();

SESSION START

01

SET SESSION DATA $_SESSION["hello"] = "world"; $hello = "world";

START/RESUME SESSION session_start();

SESSION RESUME

02

OUTPUT echo $_SESSION["hello"]; world echo $hello; gone - undefined

APPEND DATA $_SESSION["name"] = "Jon"; $_SESSION["colors"] = ["R", "G", "B"];

SESSION DATA

03

START/RESUME SESSION session_start();

UNSET DATA unset($_SESSION["hello"]);

SESSION END

04

START/RESUME SESSION session_start();

END SESSION session_destroy(); unset($_SESSION);