How To Create User Login Logout Session Timeout Using PHP
Submitted by alpha_luna on Saturday, April 23, 2016 - 09:21.
Good Day!!!
In this article, we are going to learn on How To Create User Login Logout Session Timeout Using PHP. This user login is a very common tutorial for us. In this case, we are going to add a function. In the user login, we set a session expiration time when the user logged-in. If the account of user elapsed to the set time then the user will no longer access his/her account and it will automatically log out after refreshing the page. HTML Source Code This HTML source code is to show the login form for the user.- <?php
- include("functions.php");
- $message="";
- if( $_POST["user_name"] == "admin" and $_POST["password"] == "admin") {
- $_SESSION["user_id"] = 1001;
- $_SESSION["user_name"] = $_POST["user_name"];
- } else {
- $message = "Invalid Username or Password!";
- }
- }
- if(!isLoginSessionExpired()) {
- } else {
- }
- }
- $message = "Session is Expired. Please Login Again.";
- }
- ?>
Add new comment
- 1803 views