Answering your questions separately:
How do I get session data?
Using "pure php", do the following:
$_SESSION['valor']
For example: after the client logs in, you play the client id session
$_SESSION['cliente']['id'] = $cliente->id;
$_SESSION['cliente']['nome'] = $cliente->nome;
// outros valores aqui
$_SESSION['logado'] = true;
How do I use session data to search for something related to them?
After setting the data in the session, on another page you want to fetch something from the customer id , then you would do something like this:
$cliente_id = $_SESSION['cliente']['id'];
Now just use the $cliente_id
variable where you want it (in your query for example):
$sql = 'SELECT id, placa, modelo, marca, valor
FROM veiculos
WHERE cliente_id < :cliente_id';
$sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$sth->bindParam(':cliente_id', $cliente_id, PDO::PARAM_INT);
$veiculos = $sth->fetchAll();
I used the vehicle table as an example, but in your case it could be another.
Any questions leave a comment.
Useful links: