Show Number of Page visited times using PHP

Click Here to read

This tutorial helps you to Show Number of Page visited times using PHP

PHP is a great language for Server side programming and also for web based projects. Whenever users visit your website or something else. How do they know how many times i visited this webpage. Use this Code to show how many times they visited your webpage.

 

Click Here to Join our Telegram Channel to get Instant updates

 

This will work until the user close the browser. Unlike cookies, SESSIONS stores information in variable.

session_start(); starts session
$_SESSION[‘counter’] += 1; The visitor value increase by +1 if they visit again.
$msg – msg is the variable which help you to Print the output. In the echo form.
Code:
<?php
session_start();
if( isset( $_SESSION['counter'] ) )
{
$_SESSION['counter'] += 1;
}
else
{
$_SESSION['counter'] = 1;
}
$msg = "You have visited this page ". $_SESSION['counter']." times in this session.";
?>
<html>
<body>
<?php echo ( $msg ) ?>
</body>
</html>

 

[wpdevart_like_box profile_id=”1552756811681602″ connections=”show” width=”800″ height=”170″ header=”small” cover_photo=”show” locale=”en_US”]

Was this article helpful?

Thanks

Thanks for your Feeback. It will helps us to improve our Article quality




0 Shares
+1
Tweet
Share
Stumble