} } else { if ($action == 'autologin') { // We were requested to use the remember-me function for logging in. // Note, there is no username or password for autologin ('remember me') $ulogin->Autologin(); if (!$ulogin->IsAuthSuccess()) { $msg = 'autologin failure'; } else { $msg = 'autologin ok'; } } else { if ($action == 'create') { // We were requested to try to create a new acount. // New account if (!$ulogin->CreateUser($_POST['user'], $_POST['pwd'])) { $msg = 'account creation failure'; } else { $msg = 'account created'; } } } } } // Now we handle the presentation, based on whether we are logged in or not. // Nothing fancy, except where we create the 'login'-nonce towards the end // while generating the login form. header('Content-Type: text/html; charset=UTF-8'); // This inserts a few lines of javascript so that we can debug session problems. // This will be very usefull if you experience sudden session drops, but you'll // want to avoid using this on a live website.