How can I debug PEAR auth?

Posted by croceldon on Stack Overflow See other posts from Stack Overflow or by croceldon
Published on 2010-06-09T18:02:00Z Indexed on 2010/06/13 19:32 UTC
Read the original article Hit count: 223

Filed under:
|

I have a directory on my site that I've implemented PEAR's Auth to run my authentication. It is working great.

However, I've tried to make a copy of my site (it's going to be translated to a different language), and on this new site, the Auth process doesn't seem to be working correctly.

I can login properly, but every time I try to go to a different page in the same directory, and use Auth to authorize, it forces me to login again.

Here's my logic:

$auth_options = array(
        'dsn' => mysql://user:password@server/db',
        'table' => 'users',
        'usernamecol' => 'username',
        'passwordcol' => 'password',
        'db_fields' => '*'
    );

$auth = new Auth("DB", $auth_options, "login_function");
$auth->setFailedLoginCallback('bad_login'); 
$auth->start();

if (!$auth->checkAuth())
{
  die('cannot succeed in checkAuth')
  exit;
} else {
  include("nocache.php");
}

This is part of a file that's included in every php page I that I desire to require authentication. I can login properly once, but whenever I then try to go to a different page that requires authentication, it makes me login again (and I see the 'cannot succeed' die message at the bottom of the page).

Again, this solution works fine on my original site, I copied all the files, and only changed the db server/password - it still doesn't work. And I'm using the same webhost for both.

What am I doing wrong here? Or how can I debug this further?

© Stack Overflow or respective owner

Related posts about php

Related posts about pear