{myadvertisements[zone_1]}
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to session timeout warning with countdown using PHP, Ajax and HTML
#1
In this tutorial we will show you how to display session timeout warning with countdown using PHP, Ajax and HTML.When user logged in using login form we display a countdown and after the countdown end user will be logged out automatically. 
HTML and jQuer Code

Code:
<html>
   <head>
       <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
       <script type="text/javascript">
           function start_countdown()
           {
               var counter = 10;
               myVar = setInterval(function ()
               {
                   if (counter >= 0)
                   {
                       document.getElementById("countdown").innerHTML = "You Will Be Logged Out In <br>" + counter + " Sec";
                   }
                   if (counter == 0)
                   {
                       $.ajax
                       ({
                           type: 'post',
                           url: 'logout.php',
                           data: {
                               logout: "logout"
                           },
                           success: function (response)
                           {
                               location.reload();
                           }
                       });
                   }
                   counter--;
               }, 1000)
           }
       </script>
   </head>
   <body>
       <?php
       if (@$_SESSION['password'] == "123456" && @$_SESSION['name'] == "123456") {
           ?>
           <script>start_countdown();</script>
           <p id="countdown"></p>
           <?php
       }
       ?>
   </body>
</html>

PHP Code (logout.php)


Code:
<?php
if(isset($_POST['logout']))
{
unset($_SESSION['name']);
unset($_SESSION['password']);
echo "success";
exit();
}
?>

To Purchase Credit Click here , For how to make money on Sologet forum Click here 

HIRE ME FOR WEBSITE DESIGNING USE THE PM BUTTON TO SEND ME MESSAGE

There is love in sharing
{myadvertisements[zone_3]}
#2

This is a good skill also

https://jiji.ng/gwarinpa/computer-and-it...4mHTK.html


{myadvertisements[zone_3]}
  


Possibly Related Threads…
Thread Author Replies Views Last Post
  technical help john8520 0 131 01-29-2021, 05:35 AM
Last Post: john8520
  TIPS How to add one day in current date using php Kingsolomon 1 1,588 04-14-2020, 01:16 AM
Last Post: Shugudun
  TIPS How to get Page Loading Time using PHP Kingsolomon 2 1,510 04-14-2020, 01:01 AM
Last Post: Shugudun
  How to read more / hide text using Jquery and PHP Kingsolomon 1 1,299 04-14-2020, 12:57 AM
Last Post: Shugudun
  How to limit text length in php and provide 'Read more' link Kingsolomon 1 1,563 04-14-2020, 12:43 AM
Last Post: Shugudun

Forum Jump:


Users browsing this thread:
1 Guest(s)

{myadvertisements[zone_2]}
How to session timeout warning with countdown using PHP, Ajax and HTML00