title: Create limit date for login in PHP Script
body: <p>This simple script doesn't need database, the usernames and passwords will define in the script.<br>
  How can I build the script to define a date for each username and password so that after the date expires the ability to log in using those credentials to also expire?</p>
  
  <p><strong>Like this:</strong>   </p>
  
  <pre><code>$LOGIN_INFORMATION = array(  
  'you' =&gt; 'yourpassword' =&gt; '12-03-2012'  
  'username2' =&gt; 'yourpassword2' =&gt; '12-05-2012'  
  );
  </code></pre>
  
  <p>Script Demo: <a href="http://demos.savasplace.com/password/" rel="nofollow">http://demos.savasplace.com/password/</a>  </p>
  
  <pre><code>&lt;?php
  ##################################################################
  ##           Sava's Place.com Password Protect                  ##
  ##       Visit http://savasplace.com for more scripts           ##
  ##################################################################
  $LOGIN_INFORMATION = array(
    'sava' =&gt; 'sava',
    'you' =&gt; 'yourpassword'
  );
  
  // Require username or not
  // If you want to use username and password login leave this true.
  // If you want only to request a password set it for false.
  
  define('USE_USERNAME', true);
  
  // To password protect your pages you need to include this file in them
  // To get the correct code for inclusion open password.php?code in your broswer
  
  if(isset($_GET['code'])) {
    die('&lt;center&gt;&lt;font face="Verdana" size="2"&gt;Include following code into every page you would like to protect, at the very beginning (first line):&lt;br&gt;&lt;br&gt;&lt;strong&gt;&amp;lt;?php include("' . __FILE__ . '"); ?&amp;gt;&lt;/strong&gt;&lt;/center&gt;&lt;/font&gt;');
  }
  if(isset($_GET['logout'])) {
    setcookie("verify", ''); // clear password;
    die('&lt;center&gt;&lt;font face="Verdana" size="2"&gt;Logged out.&lt;/font&gt;&lt;/center&gt;');
  }
  if(!function_exists('showLoginPasswordProtect')) {
  function showLoginPasswordProtect($error_msg) {
  ?&gt;
  &lt;!-- And this is the output --&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Login to access this page&lt;/title&gt;
  &lt;META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"&gt;
  &lt;META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"&gt;
  &lt;style&gt;
  * {
  font-family:Verdana;
  font-size:12px;
  }
  a {
  color: #000000;
  text-decoration: none;
  }
  
  a:hover {
  color: red;
  text-decoration: none;
  }
  
  input {
  border: 1px solid black;
  background-color: #FFFFFF;
  }
  .bodyform {
  border-color: #000000;
  border-style:solid;
  border-width: 3px;
  width:400px;
  }
  .title {
  color: #FFFFFF;
  background: #000000;
  padding: 5px;
  
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;center&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;div class="bodyform" align="center"&gt;
  &lt;form method="post"&gt;
  &lt;div class="title"&gt;
  &lt;strong&gt;Access restricted - Login Below:&lt;/strong&gt;
  &lt;/div&gt;
  &lt;div style="padding-right:10px;padding-left:10px;"&gt;
  &lt;font color="red"&gt;&lt;strong&gt;&lt;?php echo $error_msg; ?&gt;&lt;strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;
  &lt;?php if (USE_USERNAME) echo '&lt;table&gt;
  &lt;tr&gt;
  &lt;td align="left"&gt;Login:&lt;/td&gt;
  &lt;td align="right"&gt;&lt;input type="input" name="access_login" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Password:&lt;/td&gt;'; ?&gt;
  &lt;td&gt;&lt;input type="password" name="access_password" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;input type="submit" name="Submit" value="Submit" /&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;br /&gt;
  Powered by &lt;a href="http://savasplace.com" target="_blank"&gt;Sava's Place Password Protect Script&lt;/a&gt;
  &lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php
    die();
  }
  }
  if (isset($_POST['access_password'])) {
    $login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
    $pass = $_POST['access_password'];
    if (!USE_USERNAME &amp;&amp; !in_array($pass, $LOGIN_INFORMATION)
    || (USE_USERNAME &amp;&amp; ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) ) 
    ) {
      showLoginPasswordProtect("Incorrect password.");
    }
    else {
      setcookie("verify", md5($pass));
      unset($_POST['access_login']);
      unset($_POST['access_password']);
      unset($_POST['Submit']);
    }
  
  }
  else {
    if (!isset($_COOKIE['verify'])) {
      showLoginPasswordProtect("");
    }
    $found = false;
    foreach($LOGIN_INFORMATION as $kay=&gt;$val) {
      if ($_COOKIE['verify'] == md5($val)) {
        $found = true;
        break;
      }
    }
    if (!$found) {
      showLoginPasswordProtect("");
    }
  }
  ?&gt;
  </code></pre>