hi how can i fetch data from the database and stroe it into session variable.
my code:
$sql = "SELECT password, fullname, username, active FROM ".$mysql_table." WHERE (username = :username OR email = :username) AND password = :password";
$statement = $pdo->prepare($sql);
$statement->bindValue(':username', $_POST['username']);
$statement->bindValue(':password', md5($_POST['password']));
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
if (count($result) == 1)
{
if (session_id() == "")
{
session_start();
}
$_SESSION['username'] = ;
$_SESSION['fullname'] = ;
$_SESSION['expires_by'] = time() + $session_timeout;
$_SESSION['expires_timeout'] = $session_timeout;
$rememberme = isset($_POST['rememberme']) ? true : false;
if ($rememberme)
{
setcookie('username', $_POST['username'], time() + 3600*24*30);
}
if(!isset($_COOKIE['redirect'])) {
$redirect_page_no = './index.php';
header('Location: '.$redirect_page_no);
exit;
}
else
{
$redirect_page = $_COOKIE["redirect"];
header('Location: '.$redirect_page);
exit;
}
}
in the line 15 and 16 i want to store the username and fullname value fetched from the database.
$_SESSION['username']
$_SESSION['fullname']
how do i do it?