Count Visits with session : _SESSION « Cookie Session « PHP






Count Visits with session

 
<?php
     session_start();  #start a session

    if ( !isset( $_SESSION['count'] ) ) 
     $_SESSION['count'] = 1; else $_SESSION['count']++;
?>


<html>
<head>
<title>Count Visits</title>
</head>

<body>
<h2>You have visited this page <?php echo( $_SESSION['count'] ); ?> times in this session</h2>

</body>
</html>
  
  








Related examples in the same category

1.Counting page accesses with a session
2.Implementing Sessions
3.Printing session data
4.Registering a variable by including it in $_SESSION
5.Session based counter
6.Session preferences
7.Session using the proper $_SESSION super global
8.Verifying session info
9.check for a valid login in sessions
10.create_session_variable.php
11.delete_session_variable.php
12.Doing something special for a logged in user
13.Setting Up Cookie Authentication