As per my theory and Pastebin.com file at http://pastebin.com/439xPdJN
Here is a working demo with 2 files, and an example in order to show you that it can be done.
Modify to suit.
First, some instructions on how to use it:
You will need to to reload the page (session1.php) a few times in order to get the number up.
Then, you will notice the page view count will go back to ZERO once you confirm the logout button.
Credit goes out to: (felipsmartins) for his JS example.
The code:
Let's call this session1.php file
<?php
session_start();
if(isset($_SESSION['views']))
$_SESSION['views'] = $_SESSION['views']+ 1;
else
$_SESSION['views'] = 1;
echo "views = ". $_SESSION['views'];
?>
<!doctype html>
<head>
</head>
<body>
<script type="text/javascript">
function logoutck() {
var r = confirm("Do you really want to log out?");
if (r) {
window.location.href = 'logout.php'
}
}
</script>
<input id="button1" type='button' onclick='logoutck();' value='LOGOUT'/>
</body>
</html>
Let's call this logout.php file
<?php
session_start();
if(isset($_SESSION['views']))
unset($_SESSION['views']);
header("Location: session1.php");
?>
PHP(HTTP)/HTML/JS/CSSknowledge, which you should as a webdev, you cannot make this mistake. This is the result of learning the basics from online tutorials vs. reading books. So go read a book!