//start the session session_start(); //check if the counter is set and if not, initialize it if(!isset($_SESSION['counter'])) { $_SESSION['counter'] = 0; } //increment the session counter $_SESSION['counter']++; //display it echo 'Session counter is '.$_SESSION['counter'];