query( "SELECT * from user where email like ? and hash = ?", $strEmail, $strHash); if (count($varUsers) !== 1) throw new Exception("Zero or more than one user returned for credentials provided"); $strToken = sha1(microtime()); $c->query("CREATE table if not exists tokens ( id integer primary key autoincrement, email text not null, token text not null, expires timestamp null)"); $c->query( "INSERT into tokens (email, token) values (?, ?)", $strEmail, $strToken); Cookie::set("token", $strToken); BootstrapRender::message( "Successfully signed in", "info"); Respond::redirect("/user/info"); } } catch (Exception $x) { BootstrapRender::message($x->getMessage(), "danger"); } ?>