Complete the code to start a session in PHP.
<?php
session_[1]();
?>The session_start() function is used to start a new session or resume an existing one.
Complete the code to unset a specific session variable named 'user'.
<?php
unset($_SESSION[1]);
?>To remove a session variable, use unset($_SESSION['variable_name']) with square brackets and quotes.
Fix the error in the code to destroy the session properly.
<?php
session_start();
session_[1]();
?>The correct function to destroy a session is session_destroy().
Fill both blanks to unset all session variables and then destroy the session.
<?php session_start(); [1] = array(); session_[2](); ?>
Setting $_SESSION to an empty array removes all session variables. Then session_destroy() ends the session.
Fill all three blanks to properly destroy a session and delete the session cookie.
<?php session_start(); $_SESSION = array(); if (ini_get('session.use_cookies')) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - [1], $params[2], $params[3], true, true); } session_destroy(); ?>
To delete a cookie, set its expiration time to a past time like time() - 0. The cookie path and domain are taken from $params['path'] and $params['domain'].