2

i'm started to use webmatrix and now iam using php starter site template.

in this template you cant login. i searched all codes than i found it doesnt create session. maybe it creates but dont pass to other pages.

if there is user(logon.php):

if ($statement->num_rows == 1)
{

    $statement->bind_result($uid,$uname);
    $statement->fetch();
    $_SESSION['userid']=$uid;
    $_SESSION['username']=$uname;
    echo $_SESSION['username']; // yes its printing username
    header ("Location: index.php");
}

check(header.php):

  if (logged_on())
    {
        echo '<li><a href="/logoff.php">Sign out</a></li>' . "\n";
    }

logged_on function:

function logged_on()
{
    return isset($_SESSION['userid']); //empty
}

1 Answers1

0

Just write

session_start();

on the top of the page

Sagar Kadam
  • 487
  • 1
  • 3
  • 10