tags:

views:

109

answers:

1

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?

A: 

Ok - it looks like my webhost is having a problem with sessions on PHP (at least for this site).

Here's what they tried that worked. The following is in an .htaccess file:

php_value session.gc_probability 1
php_value session.gc_divisor 100
php_value session.gc_maxlifetime 3600
php_value session.save_path /path/to/sessions/folder

Hope this helps someone else!

croceldon