Untitled

 avatar
unknown
plain_text
10 months ago
1.9 kB
16
Indexable
//login.php

 include(ROOT_PATH.'server.php')

    <form method="post" action="login.php">

    <div class="input-group">
    		<label>Username</label>
    		<input type="text" name="username">
        <p class="form-info"></p>
    	</div>

    	<div class="input-group">
    		<label>Password</label>
       
    		<input type="password" name="password" autocomplete="new-password">
         <p class="form-info">Password we have sent you on the email you have provided when registering on this license portal. <a href="forget_password.php">Lost your password?</a></p>
        
    	</div>


      <div class="input-group form-checkbox-section">
         <label class="form-checkbox"><input type="checkbox" name="remember_me">Remember me</label>
        </div>

        <button type="submit" class="btn submit-btn" name="login_user">Login</button>

        </form>





//server.php

 if (isset($_POST['login_user'])) {
    
    $username = trim($_POST['username']);
        $pass = trim($_POST['password']);
        $remember_me = isset($_POST['remember_me']) ? $_POST['remember_me'] : null; 

        //tests if valid


        $_SESSION['username'] = $username;
        $_SESSION['user_id'] = $user_id;
        $_SESSION['last_active'] = time();

         header('location:'.BASE_URL.'member.php');
         exit;

 }


 //member.php

  //active sesssion time
    $inactive = 20 * 60; // seconds
    ini_set('session.gc_maxlifetime', $inactive); // set the session max lifetime

    session_start(); 


     if (!isset($_SESSION['username']) && !isset($_SESSION['user_id'])) {
        header('location:login_test.php');
        exit;
    }


    if (isset($_SESSION['user_id']) && (time() - $_SESSION['last_active'] > $inactive)) {
        session_unset();    
        session_destroy();  
    }
    $_SESSION['last_active'] = time(); // Update session

Editor is loading...
Leave a Comment