Page 1 of 1

logon wont stayed logged on!

Posted: Mon Oct 27, 2003 5:04 pm
by taech
heres my login(.php) page:

Code: Select all

<?php
session_start();
$username = $_POST&#1111;'username'];
$password = $_POST&#1111;'password'];

if(!$_POST)
&#123;
include 'html/loginform.html';
&#125;
elseif((!$username) || (!$password))
&#123; 
    echo "Please enter ALL of the information! <br />"; 
    include 'html/loginform.html';
&#125;
else
&#123;
	$qstr = "SELECT * from members where username = '$username' and password = '$password'";
	$result = mysql_query($qstr);
	if (mysql_num_rows($result))
	&#123;
	$result = mysql_fetch_array($result);
		$banned = $result&#1111;"banned"];
		$email = $result&#1111;"email"];
		$name = $result&#1111;"name"];
		$password = $result&#1111;"password"];
		$points = $result&#1111;"points"];
		$post = $result&#1111;"post"];
		$user_level = $result&#1111;"user_level"];
		$_SESSION&#1111;'banned'] = $banned;
		$_SESSION&#1111;'email'] = $email;
		$_SESSION&#1111;'name'] = $name;
		$_SESSION&#1111;'password'] = $password;
		$_SESSION&#1111;'points'] = $points;
		$_SESSION&#1111;'post'] = $post;
		$_SESSION&#1111;'user_level'] = $user_level;
		$_SESSION&#1111;'username'] = $username;
		echo "<br><font color=#008000><Center><b>**Successful Login**</b></Center></font>";
	&#125;
	else
	&#123;
		echo "<br><font color=#ff0000><Center><b>**Failed Login**</b></Center></font>"; 
	&#125;
&#125;
?>
and as stated in the title, when I login it wil login all right, but then when i got to the next page, it forgets that i have logged on :(...

so, any help?

-thx

Posted: Mon Oct 27, 2003 5:06 pm
by m3rajk
becuase post isn't set on all pages. it can be on form pages, but not on all. do you check for the session variable to see if someone's logged in anywhere?

Posted: Mon Oct 27, 2003 5:29 pm
by d3ad1ysp0rk
do you have session_start(); on all pages?

and do you declare
$username = $_SESSION['username'];
and
$password = $_SESSION['password'];
on each page?

Posted: Mon Oct 27, 2003 5:58 pm
by taech
m3rajk i do know that post isnt set on all pages also i do check the sessions but only where i need it.

yes i do LiLpunkSkateR

Posted: Mon Oct 27, 2003 6:04 pm
by JAM
What do you see if you;

Code: Select all

// change...
echo "<br><font color=#008000><Center><b>**Successful Login**</b></Center></font>";

// ...to...
echo "<br><font color=#008000><Center><b>**Successful Login**</b></Center></font>";
echo '<pre>';
print_r($_SESSION);
echo '</pre>';

Posted: Mon Oct 27, 2003 6:32 pm
by taech
**Successful Login**

Array
(
[banned] => 0
[email] => email@email.com
[name] => myname
[password] => mypass
[points] => 10
[post] => 0
[user_level] => 3
[username] => admin
)

Posted: Mon Oct 27, 2003 6:48 pm
by JAM
Bah, I was hoping that I could narrow it down abit, but no. As that works the session is indeed set. Other thing i thought of was missing to use session_start() on the next page, but you allready stated that you did...

Sorry, but I'm stumped...

Posted: Tue Oct 28, 2003 6:54 am
by zenabi
Not sure if this will help, but I found this from php.net:
If you have problems with getting "session_start()" working on a Windows XP machine try this:
Change "session.save_path" in the "php.ini" file from "session.save_path = /tmp" to "C:\WINDOWS\Temp".