am trying to get the id in another page bu i always got nulls whats wrong with my code here ? and how to fix it ? ** the problem is in ->
public function login($email, $password) {
$db = new database(); //connection with database
$q = "select * from user where
email='$email'
AND
password='$password'";
$db->pQuery($q);
$userSet = $db->fetchAll();
// var_dump($userSet);die;
if (!empty($userSet)) {
// session_start();
$_SESSION["username"] = $email;//not null
$_SESSION["userid"] = $userSet['id'];//null
print_r( $_SESSION["userid"]);
var_dump($_SESSION["userid"]);die;
header("location:search.php");
exit();
} else {
return false;
}
}
in the other page :
<?php
session_start();
$id = $_SESSION['userid'];//==null
echo $id;//null here
var_dump($id);//null here
Aucun commentaire:
Enregistrer un commentaire