Question regarding PEAR::Auth package
<p>I am a newbie to PHP development. I tried following code sample from PHP5 Power Programming book:  </p>

<pre><code>&lt;?php
require_once 'DB.php';
require_once 'PEAR.php';
require_once 'Auth.php';

$auth_options = array(
'dsn' =&gt; 'mysql://username:password@localhost/database',  
'table' =&gt; 'users',  
'usernamecol' =&gt; 'username',
'passwordcol' =&gt; 'password',
'db_fields' =&gt; '*',
);
PEAR::setErrorHandling(PEAR_ERROR_DIE);
$auth = new Auth('DB', $auth_options);
$auth-&gt;start();
if (!$auth-&gt;getAuth()) {
exit;
}
if (!empty($_REQUEST['logout'])) {
$auth-&gt;logout();
print "&lt;h1&gt;Logged out&lt;/h1&gt;\n";
print "&lt;a href=\"$_SERVER[PHP_SELF]\"&gt;Log in again&lt;/a&gt;\n";
exit;
}
print "&lt;h1&gt;Logged in!&lt;/h1&gt;\n";

if (!empty($_REQUEST['dump'])) {
print "&lt;pre&gt;_authsession = ";
print_r($_SESSION['_authsession']);
print "&lt;/pre&gt;\n";
} else {
print "&lt;a href=\"$_SERVER[PHP_SELF]?dump=1\"&gt;Dump session&lt;/
?a&gt;&lt;br&gt;\n";
}
print "&lt;a href=\"$_SERVER[PHP_SELF]?logout=1\"&gt;Log Out&lt;/a&gt;\n";

?&gt;
</code></pre>

<p>there are several problems I am having with this code:  </p>

<ol>
<li>First, when I log in I get following warnings:<br>
Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in /usr/local/php5/lib/php/Auth.php on line 830<br>
Warning: Cannot modify header information - headers already sent by (output started at /home/myaccount/www/www/test.php:2) in /usr/local/php5/lib/php/Auth.php on line 858  </li>
</ol>

<p>Why am I getting these?  </p>

<ol>
<li>Second, when I click on the Dump session link, it asks me to log in again - i.e., does not recognize that I am already authenticated and logged in.  </li>
</ol>

<p>Could some please explain these to me? Thanks. </p>
