neridaj wrote:$username is set at login:
Where does it come from? It sounds like you should be using $_POST['username'] instead of $username since it comes from a login form. I would then expect something like this:
// include function files for this application
require_once 'bookmark_fns.php';
session_start();
if (isset($_POST['username'], $_POST['passwd']))
{
// they have just tried logging in
try
{
login($_POST['username'], $_POST['passwd']);
// if they are in the database register the user id
$_SESSION['valid_user'] = $_POST['username'];
}
catch(Exception $e)
{
echo $e->getMessage();
// unsuccessful login
do_html_header('Problem:');
do_html_url('login.php', 'Login');
do_html_footer();
exit;
}
}
Also, set error_reporting to E_ALL in php.ini so you can be warned of such potential problems.
SumitGupta wrote:Can you please try to have Ob_start() and ob_flush(), I suspect some white spaces are coming before you are start the session and maybe that is stopping from session start.
If whitespace before headers are sent is the problem, the solution is to remove or move the whitespace, not use output buffering.