<?php
session_start();
if(isset($_SESSION['views']))
$_SESSION['views'] = $_SESSION['views']+ 1;
else
$_SESSION['views'] = 1;
echo "views = ". $_SESSION['views'];
?>
Is $_SESSION['views'] initialized as FALSE?
EDIT: I meant the third line of code:
if(isset($_SESSION['views']))
If I understand correctly, it’s like this: if the user has never been to your site, then you are starting a new session and
$_SESSION['views']will not be set (so you set it to 1). On the other hand if the user’s request comes with a session ID of a valid session, then the variable will be set to whatever it was last stored as.