connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX); if ($con->checkpwdmd5 ("admin", md5 ($pwd))) { // cookie will be valid for 2 weeks. I've chosen that value // arbitrarily, and it may change in the future. $time = time () + 14 * 60 * 24 * 60; $cookie_name = sprintf ("%sauth", DBPREFIX); setcookie ($cookie_name, md5 ($pwd), $time, "" , "", false, true); access_allowed (); } else { access_denied (); } } if ($_GET ["logout"] == "true" || $_GET ["logout"] == "1") { logout (); } try { main ($connection); } catch (Exception $e) { access_denied (); } ?>