/** * Process an AJAX call from the login form * Input: * user name, password * Output: * HTTP status code, completion message, user name and session * cookies set. */ public function run() { if ($this->validInput()) { if ($this->loginUser()) { Cookies::setLoginCookies($this->nickName, $this->id, $this->firstName, $this->lastName); print 'Success!'; } } }
<?php require_once '../c_config.php'; $session = new Sessions(); $i = null; // just a helper for error checking if (isset($_POST["submit"])) { $username = $_POST["username"]; $password = $_POST["password"]; if (verifyUser($username, $password)) { $id = Users::getIdByUsername($username); Cookies::setLoginCookies($id, 30); // remember for 30 dayz! $session->setSession($id, $username); $i = false; } else { $i = true; } } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="js/jquery.min.js"></script> <link href="css/login.css" rel='stylesheet' type='text/css' /> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script> <title>ccms Admin Login</title> </head>