Hi,
Just playing around with one of my php4.3 projects in a new php5/apache2/mysql4.1/win32 environment and found that it doesn't carry the sessions to other scripts.
I have the standard headers located at the top of the common php header file that is called by all other scripts.
ini_set('session.use_trans_sid', false);
session_start();
the auth.php verifies user information as follows:
$salt = substr($_REQUEST['pass'], 0, 2);
$encrypted_pswd = crypt($_REQUEST['pass'], $salt);
$result = mysql_query("SELECT id,username,password,acclev,accexp from members where username='".$_REQUEST['username']."'");
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result) ) {
if (($row['username'] == $_REQUEST['user']) && ($row['password'] == $encrypted_pswd)) {
if (isset($row['accexpired']) {
$logged_in = 3;
} else {
$_SESSION['name'] = $row['id'];
$_SESSION['userlev'] = $row['acclev'];
$logged_in_name = $row['name'];
$logged_in = 1;
}
} else {
$logged_in = 0;
}
}
}
(my code maybe a bit rough, I'm still relatively new)
and then it gives the obligatory "you are now logged in" message and then performs a javascript redirect back to the main page.
when probing for the sessions on the index page, I'm getting no session variables..
Only seems to be happening with this script... other projects carry the variables ok, so I haven't bothered looking at the php.ini file.
On another note, is there a better way to retrieve one record from a database than as an enumerated array?
Any idea's?