Complete the code to start a session in PHP.
<?php
[1]();
?>In PHP, session_start() is used to begin a session or resume the current one.
Complete the code to store a value in the session.
<?php session_start(); $_SESSION['user'] = [1]; ?>
Session values must be assigned as strings or variables. Here, "John" is a string value stored in the session.
Fix the error in the code to correctly check if a session variable is set.
<?php session_start(); if (isset([1]['user'])) { echo "User is logged in."; } ?>
The correct superglobal array for sessions is $_SESSION with uppercase SESSION and a leading dollar sign.
Fill both blanks to correctly unset a session variable and destroy the session.
<?php session_start(); unset([1]['user']); [2](); ?>
To remove a session variable, use unset($_SESSION['user']). To end the session, use session_destroy().
Fill all three blanks to create a session variable, check it, and print it.
<?php [1](); if (isset([2]['count'])) { echo [3]['count']; } else { echo "No count set."; } ?>
Start the session with session_start(). The session array is $_SESSION. Use it to check and print the 'count' variable.