I have a page which sets url parameters. I want to store them in a session so that they are always in the shopping cart but the session gets overwritten and there is always only one item in the cart.
<?php
// Start the session - session was set in book details and/or library search page
session_start();
if (isset($_GET['title']) && $_GET['title'] !== ""){
$_SESSION['name'] = array();
$title = $_GET['title'];
array_push($_SESSION['name'],$title);
}
Retrieving the session details
<?php
foreach ($_SESSION['name'] as $key => $val) {
echo $val;
}
$_SESSION['name'] = array();create an empty array every time it's executed?