Others answers are ok-ish, but i like more this solution, it also check if session is just started (so $_SESSION['saved_names']
is not set yet) :
<?php
session_start();
$_SESSION['saved_names'] = isset( $_SESSION['saved_names']) ? $_SESSION['saved_names'] : [];
if($_GET['saved_name']){
$_SESSION['saved_names'][] = $_GET['saved_name'];
}
echo '<pre>', print_r($_SESSION['saved_names'], true), '</pre>';
?>
Edit
@elitepc solution (as he said) is not working because
$saved_names = array(); /empty array
$saved_names = $_SESSION['saved_names']; / <- it has not been declared also will never update
And then
$saved_name = $_GET['saved_name'];
$saved_names[] = $saved_name;
So basically everytime it just creates an empty array and put inside the $_GET
value.
You have to check if the session variable it's been initialized and in case update it with $_GET
value