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
PHP session
Moderator: General Moderators
- lonelywolf
- Forum Commoner
- Posts: 28
- Joined: Tue Jun 10, 2008 6:15 am
Re: PHP session
why did you use $_SESSION variable in lowercase while manual and tutorials are in uppercase
. Change $_session to $_SESSION will solve your problem!