My sessions dont work, and ive followed all of those steps "/tmp" --> "C:\temp" and register_globals = off and numerous others. Ive narrowed it down to this. The session files are being created, I can store data into an SQL database, but i Just cant transfer data to a session file for some reason, even tho the session files are generated but all contain this.
"first_name|N;last_name|N;email_address|N;special_user|N;user_level|s:1:"0";"
I have apache 1.3 w/ PHP 4.3 and my session variables in the PHP.INI are correct. Is there a list of steps i should try? Here is an example of what my scripts contain and what it does.
- Code: Select all
1st file = "checkuser.php"
<?
/* Check User Script */
session_start(); // Start Session
include 'db.php';
// Conver to simple variables
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo "Please enter ALL of the information! <br />";
include 'login_form.html';
exit();
}
// Convert password to md5 hash
$password = md5($password);
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
session_register('first_name');
$_SESSION['first_name'] = $first_name;
session_register('last_name');
$_SESSION['last_name'] = $last_name;
session_register('email_address');
$_SESSION['email_address'] = $email_address;
session_register('special_user');
$_SESSION['user_level'] = $user_level;
header("Location: login_success.php");
mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");
}
} else {
echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br />
Please try again!<br />";
include 'login_form.html';
}
?>
2nd file = "login_success.php"
<?
session_start();
echo "Welcome ". $_SESSION['first_name'] ." ". $_SESSION['last_name'] ."! You have made it to the members area!<br /><br />";
echo "Your user level is ". $_SESSION['user_level']." which enables you access to the following areas: <br />";
if($_SESSION['user_level'] == 0){
echo "- Forums<br />- Chat Room<br />";
}
if($_SESSION['user_level'] == 1){
echo "- Forums<br />- Chat Room<br />- Moderator Area<br />";
}
echo "<br /><a href=logout.php>Logout</a>";
?>
And the output is..
Welcome ! You have made it to the members area!
Your user level is which enables you access to the following areas:
- Forums
- Chat Room
Logout
Notice the
- Code: Select all
$first_name and $last_name
do not exist? also the user level is not present? Can you tell me what could be causing this to happen?
I also have a router, im using apahce 1.3 w/ php4.3, i switched from apache2 to apache 1.3, no luck. Please help!