PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 31, 2022

[FIXED] How can I debug PEAR auth?

 August 31, 2022     pear, php     No comments   

Issue

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?


Solution

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!



Answered By - croceldon
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing