Code to get page views in php when you refresh more and more views increases . You can store this data to server and get the pageviews. You have to just put this file in your server
ViewCount.php
<?php
session_start();
if(isset($_SESSION['views']))
$_SESSION['views'] = $_SESSION['views']+1;
else
$_SESSION['views']=1;
echo"views = ".$_SESSION['views'];
?>
Output:
views = 1
Refresh the browser
views = 2Now how to reset the page views count . It will help
to store data of daily page views. I.e you will get day wise ,
monthly wise , yearly wise data . Stored in different table.
The following code can be used to reset the views count to 1.
//countReset.php <?php session_start(); $views = $_SESSION['views']; //retrieve the session variable unset($_SESSION['views']); //to remove session variable session_destroy(); //destroy the session ?>If you like this please share and like our Facebookpage
Comments
Post a Comment