how do i use session php to display info

De Code

Newbie
Joined
May 14, 2018
Messages
12
Reaction score
0
Hello,

how do i use the session.php to display information for example profile page

i did this , could anyone help
PHP:
$query = "SELECT userintake from login where username = '$user_check'";
$ses_sql = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($ses_sql);
$userintake = $row['userintake'];

how do i show userintake variable on a page?
 
Provided all the code above is correct, then there are a number of ways, but here are two:

<? echo $userintake; ?>
<?= $userintake; ?>

This is just my way... if there’s logic involved, then it’s with echo, and if it’s just displaying the data or setting a value attribute in a form field, I use <?=
 
If you want to assign it to a session variable do this:
$_SESSION['userintake'] = $userintake;

echo $_SESSION['userintake]' // this will print the variable into the page.

Don't remember to call at the very first row of the page a session_start();
 
Back
Top