I'm making a login system, but when a user logs in, it doesn't actually store any of the data i want it to in the session. I even checked the session's file, and it was empty. I have session_start(); on all the pages. what else could i be doing wrong. Heres the code for the two main pages.
the login code:
<?
if ($DEBUG == true) {
error_reporting(E_ALL);
}
require "header.php";
require_once "dbinterface.php";
require_once "user.class.php";
require_once "config.inc.php";
$db = new db($DB['host'], $DB['user'], $DB['pass'], $DB['database']);
$u_result = $db->run("select user_id from users where user_name = '" . $db->escape($_POST['user_name']) . "'");
if ($u_result == false) {
$url = 'Location: error.php?id=8';
header($url);
}
if (count($u_result) < 1) {
$url = 'Location: error.php?id=3';
header($url);
}
$user = new user($u_result[0]['user_id']);
if ($user->match_password($_POST['pass']) == true) {
$_SESSION['authenticated'] = true;
$_SESSION['user_id'] = $u_result[0]['user_id'];
$_SESSION['user'] = $user;
} else {
$url = 'Location: error.php?id=4';
header($url);
}
session_write_close();
header('Location: index.php');
?>
The header that gets included in every page:
<?php
if (!session_start()) {
$url = "Location: error.php?id=13";
header($url);
}
?>
A little background:
- windows 7 (also tried on windows
- server 2008, but currently on 7) PHP
- 5 localy hosted problem is present
- for everyone problem exists in all
- browsers