本文整理汇总了PHP中auth::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP auth::authenticate方法的具体用法?PHP auth::authenticate怎么用?PHP auth::authenticate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth
的用法示例。
在下文中一共展示了auth::authenticate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process()
{
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username)) {
lib::seterror('Please enter a username.');
lib::sendto('/login');
}
if (empty($password)) {
lib::setitem('username', $username);
lib::seterror('Please enter a password.');
lib::sendto('/login');
}
$user = new user(array('username' => $username));
if (auth::authenticate($user, $password)) {
lib::setitem('user', $user);
lib::sendto();
} else {
lib::setitem('username', $username);
lib::seterror('Invalid username or password.');
lib::sendto('/login');
}
}
示例2: auth
// Use Sessions
// WARNING: Vulnerable to javascript injection.
// NOTE: This will store the username and password entered by the user to the cookie
// variables USERNAME and PASSWORD respectively even if the combination is correct or
// not. Be sure to authenticate every page that you want to be secured and pass as
// parameters the variables USERNAME and PASSWORD.
setcookie("USERNAME", $_POST['username']);
setcookie("PASSWORD", $_POST['password']);
// Change the path to auth.php and authconfig.php if you moved
// vAuthenticate.php from its original directory.
include_once "auth.php";
include_once "authconfig.php";
$username = $_POST['username'];
$password = $_POST['password'];
$Auth = new auth();
$detail = $Auth->authenticate($username, $password);
if ($detail == 0) {
?>
<HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<?php
echo $failure;
?>
");
//-->
</SCRIPT>
</HEAD>
<?php