07 Feb, 2018

How to Create Auto Logout Script in PHP

07 Feb, 2018

Dear Reader, let us know that, “How to Create Auto Logout Script in PHP with Live Demo“. So in this Tutorial, We Learn Step By Step “How to Create Auto Logout Script in PHP”.

If You have any Web Application and You want to Logout Logged In User After Some time then Article for You. If there is no activity till 60 Seconds then a warning message will be shown and after 30 Seconds you will be auto logout.

First, we see Snapshot for Auto Logout Script Form

auto-logout-ascript-in-php-step-1

And you can also see Live Demo by click on bellow Demo button

Step 1:- At first we need to Create “header.php” file in Our Project Root Directory as “your_project_name/header.php “ like “webpreprations/demo/auto-logout-in-php/header.php” and paste below code

Step 2:- At first we need to Create “index.php” file in Our Project Root Directory as “your_project_name/index.php “ like “webpreprations/demo/auto-logout-in-php/index.php” and paste below code

Step 3:- Now we need to Create “user_dashboard.php” file in Our Project Root Directory as “your_project_name/user_dashboard.php “ like “webpreprations/demo/auto-logout-in-php/user_dashboard.php” and paste below code

Step 4:- Now we need to Create “script.js” file in Our Project Root Directory as “your_project_name/script.js “ like “webpreprations/demo/auto-logout-in-php/script.js” and paste below code

Step 5:- Now  Create “logout.php” file in Our Project Root Directory as “your_project_name/logout.php “ like “webpreprations/demo/auto-logout-in-php/logout.php” and paste below code

Step 6:- At Last for run your project open browser and type in URL like “localhost/your_project_name/index.php”

like

localhost/webpreprations/demo/auto-logout-in-php/index.php

you can see the result as we can see in below snapshot

auto-logout-ascript-in-php-step-1

Step 7:- Now we need to Login We use Username – “webpreoarations” and Password – “123456” after login you will be Redirected User Dashboard as below snapshot

auto-logout-ascript-in-php-step-2

Step 8:- In This Article, We set Session Expiration time “2 Second” so After 2 Seconds you  will be Logout and Redirected “Index.php” as below snapshot

auto-logout-ascript-in-php-step-3

Congratulations you have successfully Completed “How to Create Auto Logout Script in PHP”, if this post was helpful for you then please share this post on social media and if you have any query then please contact us or comment below and don’t forget us follow and like on Social Media, Thanks.

Related Articles
«
»

7 Comments:

  • Bhavin Patel August 24, 2018

    Hello Webpreparations,
    Where is the header.php file?
    include(‘../header.php’);

    Reply

    • Webpreparations Team August 27, 2018

      Hello Dear Reader
      Please see the step 1:- for the header.php code

      Reply

  • Rexy October 08, 2018

    Hello Webpreparations
    why when I try to click or move the mous session still running ?
    which I hope is usually this function runs when the user has no activity on page.

    Reply

    • Webpreparations Team October 09, 2018

      Thank you for contact us, we will help you soon.

      Reply

    • Webpreparations Team October 11, 2018

      Hello Rexy ,

      Please go through the article again we are updated article according to your need, We hope this will fulfill your requirements.
      Thank you for contact us, cheers 🙂

      Reply

  • Randy March 16, 2019

    Hello Webpreparations,
    Where is the functions.php?

    Reply

    • Webpreparations Team March 16, 2019

      Hello,
      There is no need for functions.php
      Please remove from the index.php
      Thank you for contact us.

      Reply

Leave a comment:

Your email address will not be published. Required fields are marked *