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 197 views
197 views asked Nov 29, 2020 by avibootz
1 answer 160 views
1 answer 183 views
183 views asked Nov 29, 2020 by avibootz
1 answer 229 views
1 answer 270 views
1 answer 162 views
1 answer 199 views
...