session_start(); // start the session $_SESSION['name'] = 'John'; // set a session variable $session_vars = session_get_cookie_params(); // retrieve all the session variables print_r($session_vars); // print all the session variables
session_start(); // start the session $_SESSION['cart'] = array('product1', 'product2', 'product3'); // set a session variable $cart = $_SESSION['cart']; // retrieve the session variable foreach($cart as $product) { echo $product . 'This example sets a session variable called 'cart' that contains an array of products. The get_list method is not used explicitly, but the session variable is accessed directly with the $_SESSION superglobal. The get_list method is part of the PHP Core Library.
'; // print each product in the cart }