<?php
session_start();
//$connect = new mysqli("localhost", "sooggoo", "4Compassion*", "evergreenint"); 
  
$_SESSION['lpono'] = $_POST['lpono'] ;
		$_SESSION['action'] = $_POST['action'] ;
	


            if (!isset($_SESSION['lpono'])) {
    // Initialize 'thirdColumnData' as an empty array if it doesn't exist
    $_SESSION['lpono'] = array();
}
	// Check if the checkbox is checked or unchecked
    if ($_SESSION['action'] === 'add') {
        // Add the age data to the session array
        if (!isset($_SESSION['lpono'])) {
            $_SESSION['lpono'] = []; // Initialize session variable as an array
        }
        // Add the age value if not already in the session
        if (!in_array($_POST['lpono'], $_SESSION['lpono'])) {
            $_SESSION['lpono'][] = $_POST['lpono'];
        }

        // Send a JSON response back to the client on accept and process batch
      echo json_encode([
         'status' => 'success',
         'message' => 'Data added to session',
          'lpono' => $_SESSION['lpono']
       ]);
		
    } elseif ($_SESSION['action'] === 'remove') {
        // Remove the age data from the session
        if (isset($_SESSION['lpono']) && ($key = array_search($_POST['lpono'], $_SESSION['lpono'])) !== false) {
            unset($_SESSION['lpono'][$key]); // Remove the data from the array
        }

        // Send a JSON response back to the client
     echo json_encode([
        'status' => 'success',
     'message' => 'Data removed from session',
      'lpono' => $_SESSION['lpono']
     ]);
    }
	
	 // foreach ($_SESSION['lpono'] as $lpo) {
     //  echo $lpo;
	//  echo "<br>";
 //   } 	



//echo $FromCust;

 exit;



?>
