Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3853444
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:28:11+00:00 2026-05-19T17:28:11+00:00

I am a newbie to PHP development. I tried following code sample from PHP5

  • 0

I am a newbie to PHP development. I tried following code sample from PHP5 Power Programming book:

<?php
require_once 'DB.php';
require_once 'PEAR.php';
require_once 'Auth.php';

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

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

?>

there are several problems I am having with this code:

  1. First, when I log in I get following warnings:
    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
    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

Why am I getting these?

  1. 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.

Could some please explain these to me? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:28:12+00:00Added an answer on May 19, 2026 at 5:28 pm

    Sessions are maintained by a cookie passed between the server and the browser in each request containing a session identifier PHP generates. Since cookies are part of HTTP headers, creation of a session by sending a cookie has to happen before your script outputs any content.

    That includes whitespace, which is the likely culprit for your error. There can be no whitespaces, including blank lines, spaces, BOMs at the top of the file before the opening <?php tag, including in the included files.

    The second error is a side effect of the first error, so once you fix that, it’ll go away as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a newbie php guy. I have 1 string output from Drupal's date module
php newbie here..I need some PHP help ideas/examples on how to import data from
I'm new to PHP and have installed on Linux to boot (also a newbie).
Newbie to LINQ, and trying to write the following query... select f.Section_ID, f.Page_ID, f.SortOrder,
i'm a newbie to iphone development. I'm doing a navigation-based app, and I'm having
I've been doing web application development for the last 3 years in PHP. I'm
Not exactly about programming, but I need help with this. I'm running a development
I'm a PHP newbie. I'm trying to use preg_match_all function in the below program
I'm very newbie to php and codeigniter (and smarty too). I follow a lot
I'm a php newbie, and I'm creating a Facebook application for my flash game.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.