0

Hello friends, I am having a confusion in my script please explain me what is it doing i don't know what it is i don't understand sessions very well, so please explain it

if (isset($_SESSION['SBUser'])) {
    $user_id =*** $_SESSION['SBUser']***;
    $query = $db->query("SELECT * FROM users WHERE id = '$user_id'");
    $user_data = mysqli_fetch_assoc($query);
    $fn =  explode(' ', $user_data['full_name']);
    $user_data['first'] = $fn['0'];
    $user_data['last'] = $fn['1'];

}

$_SESSION['SBUser']; please explain me what does it mean.

3
Contributors
2
Replies
19
Views
1 Year
Discussion Span
Last Post by madCoder
0

$_SESSION is a collection of values stored on the web server per visitor, per browser (ie, tied to the browser by a *cookie* that stores a unique *Session ID*.)

Values can be stored in $_SESSION for retrieval on the server in your PHP code in subsequent requests.

Your code snippet checks to see if the $_SESSION['SBUser'] has already been set. If so, retrieve user details from the database.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.