 <?php include('partials/menu.php'); ?>
   <?php
   if (isset($_SESSION['login'])) {
     echo $_SESSION['login'];//displaying session msg
     unset($_SESSION['login']);//REMOVING SESSION MSG
     // code...
   }
   //cookies
   $name = "somename";
   $value = 100;
   $expiration = time() + (60 * 60 *24*7);
   setcookie($name,$value,$expiration);
   //cookies
   $session = session_id();
   $time = time();
   $time_out_in_seconds = 120;
   $time_out = $time - $time_out_in_seconds;
   $sql5 = "SELECT * FROM user_online WHERE session = '$session'";
   $res5 = mysqli_query($conn, $sql5);
   $count5 = mysqli_num_rows($res5);

   if ($count5 == NULL) {
     // code...
    mysqli_query($conn, "INSERT INTO user_online(session, time) VALUES('$session', '$time')");
   }else {
     mysqli_query($conn, "UPDATE user_online SET time='$time' WHERE session = '$session'");
   }

   $sql_user = "SELECT * FROM user_online WHERE time>'$time_out'";
   $users_online = mysqli_query($conn, $sql_user);
   $count_user = mysqli_num_rows($users_online);



    ?>
     <!--main content section starts here-->
     <div class="main-content">

       <div class="wrapper">

         <h1>DASHBOARD</h1>
         <div class="col-4 text-center">
              <h3><?php echo "Active Users" ?></h3>
              <br><br>
              <h4><?php echo $count_user ?></h4>



         </div>
         <div class="col-4 text-center">
           <?php
            $sql = "SELECT * FROM tbl_category";
            $res = mysqli_query($conn, $sql);
            $count = mysqli_num_rows($res);

            ?>
           <h1><?php echo $count?></h1>
           <br>
           <?php $cat = "Categories";?>
           <a style="color:red;text-decoration:none;" href="manage-category.php"><?php echo $cat ?></a>

         </div>
         <div class="col-4 text-center">
           <?php
            $sql2 = "SELECT * FROM sub_categories";
            $res2 = mysqli_query($conn, $sql2);
            $count2 = mysqli_num_rows($res2);

            ?>
           <h1><?php echo $count2?></h1>

           <br>
           <?php $men = "Sub-Categories";?>
           <a style="color:blue;text-decoration:none;" href="manage-sub-category.php"><?php echo $men ?></a>

         </div>
         <div class="col-4 text-center">
           <?php
            $sql3 = "SELECT * FROM products";
            $res3 = mysqli_query($conn, $sql3);
            $count3 = mysqli_num_rows($res3);

            ?>
           <h1><?php echo $count3?></h1>

           <br>
           <?php $kid= "products";?>
           <a style="color:red;text-decoration:none;" href="manage-products.php"><?php echo $kid ?></a>


         </div>
        
         <div class="clearfix"></div>
       </div>

     </div>
     <!--main content section ends here-->
     <?php include('partials/footer.php'); ?>
