PHP session

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
grahamne
Forum Newbie
Posts: 6
Joined: Mon Jun 16, 2008 2:29 pm

PHP session

Post 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
User avatar
lonelywolf
Forum Commoner
Posts: 28
Joined: Tue Jun 10, 2008 6:15 am

Re: PHP session

Post 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!
Post Reply