session_start(); // Get current allowedSensors array or create a new one if it doesn't exist $allowedSensors = isset($_SESSION['allowedSensors']) ? $_SESSION['allowedSensors'] : array(); // Add new sensors to the array $newSensors = array('sensor1', 'sensor2'); $allowedSensors = array_merge($allowedSensors, $newSensors); // Update the session variable $_SESSION['allowedSensors'] = $allowedSensors;
session_start(); // Get current allowedSensors array or create a new one if it doesn't exist $allowedSensors = isset($_SESSION['allowedSensors']) ? $_SESSION['allowedSensors'] : array(); // Check if user has access to sensor3 if(in_array('sensor3', $allowedSensors)) { echo "User has access to sensor3"; } else { echo "User does not have access to sensor3"; }The package library used for php session handling is built-in and doesn't require any external library or package.