I have this code in script.php:
<?php
session_start();
$user_session = $_SESSION['u_name'];
class check_sess {
public function check_id_session($user_session, $db) { //email
$stmt = $db->prepare('select id_user from users where email=?');
$stmt->bind_param('s', $user_session);
$stmt->execute();
$stmt->bind_result($id);
if ($stmt -> fetch()) {
$id;
echo $id; // here shows 20 for example
return true;
}
else
return false;
$stmt->close();
$db->close();
}
}
?>
and in demo.php I have:
include 'script.php';
$val = new check_sess();
$val-> check_id_session($user_session, $db);
echo $id; //problem here. It is supposed echo 20
Why can't I do echo $id
? There is no output in demo.php.