How to unset all of the session variables in PHP

1 Answer

0 votes
<?php
/*
bool session_start ([ array $options = [] ] )

// With session we store information in variables that used across multiple pages
// The variables is not stored on the computer
*/
  
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php

$_SESSION["user_name"] = "ron";
$_SESSION["country"] = "usa";
echo $_SESSION["user_name"] . " - " . $_SESSION["country"];

// Unset all of the session variables
$_SESSION = array(); 

echo $_SESSION["user_name"] . " - " . $_SESSION["country"];

?>
</body>
</html>
<?php
      
/*
run:
  
ron - usa
Notice: Undefined index: user_name in C:\xampp\htdocs\workingframe.com\test.php on line 25

Notice: Undefined index: country in C:\xampp\htdocs\workingframe.com\test.php on line 25
- 

*/

?>

 



answered Dec 24, 2015 by avibootz

Related questions

1 answer 286 views
286 views asked Nov 29, 2020 by avibootz
1 answer 236 views
1 answer 280 views
280 views asked Nov 29, 2020 by avibootz
1 answer 325 views
1 answer 355 views
1 answer 246 views
1 answer 293 views
...