Page 1 of 1

PHP session

Posted: Mon Jun 16, 2008 2:33 pm
by grahamne
I am new to using php and session varaibles and im having problems using a session accross multiple pages
index
<?php
include("db.php");
session_start();
if(!isset($_session['user'])){
$_session['user'] =0;
}
else
{
echo 'logged in';
}
?>

login action page
<?php
session_start();
include("db.php");

$username = $_POST ['uname'];
$password = $_POST ['p'];
$login = @mysql_query("select * from users where username='$username'");
while($row =mysql_fetch_array($login))

{
$_session['user']=$row['id'];
//echo $_session['user'];
header('location:blah blah');
}
this returns to a page but the session is still zero and i am stuck finding a solution

Re: PHP session

Posted: Mon Jun 16, 2008 11:10 pm
by lonelywolf
why did you use $_SESSION variable in lowercase while manual and tutorials are in uppercase 8O . Change $_session to $_SESSION will solve your problem!