Last active
October 1, 2015 04:48
-
-
Save caseysoftware/1923307 to your computer and use it in GitHub Desktop.
Code to generate the password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function user_login($username, $submitted) { | |
| /** | |
| * Retrieve the temporary/one-time password. While session-based is ok for | |
| * this proof of concept, to make this more secure we'd want to use a database | |
| * some sort of timeout to expire the password of N minutes/hours. | |
| */ | |
| $stored = $_SESSION['password']; | |
| // Compare the retrieved vs the stored password | |
| if ($stored == $submitted) { | |
| $message = "Hello and welcome back $username"; | |
| } else { | |
| $message = "Sorry, that's an invalid username and password combination."; | |
| } | |
| // Clean up after ourselves | |
| unset($_SESSION['username']); | |
| unset($_SESSION['password']); | |
| return $message; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment