PHP

SIMPLE EXAMPLES OF HOW SESSIONS WORK IN PHP

* PHP GENERATES A UNIQUE SESSION ID * CREATES A SESSION FILE ON THE    SERVER  * SENDS PHPSESSID = ID COOKIE TO    THE BROWSER  session_start(); echo session_id();

SESSION START

01

START THE SESSION session_start();   DATA WILL BE STORED IN THE SESSION FILE ON THE SERVER $_SESSION["Color"] = "Red"; $_SESSION["Food"] = "Burger";

SESSION SAVE

02

* PHP READS PHPSESSID COOKIE * LOADS SESSION FILE & PARSE INTO     $_SESSION  * USER CAN ACCESS ANY PAGE &     $_SESSION IS THE SAME session_start(); var_dump($_SESSION);

SESSION RESUME

03

START THE SESSION session_start();   CLEAR ALL SESSION FILES & COOKIES session_destroy();

SESSION END

04