Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,945 questions

51,886 answers

573 users

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 179 views
179 views asked Nov 29, 2020 by avibootz
1 answer 147 views
1 answer 170 views
170 views asked Nov 29, 2020 by avibootz
1 answer 215 views
1 answer 254 views
1 answer 151 views
1 answer 180 views
...