2025-07-25 19:39:59 [::1][-][-][error][application] Invalid extra_data JSON structure: {
"order_reference_id":"PdQXOoBF53wbAVYGfLzUvhCkOaQXqx5HZy_bidlZ9MgQtIkZJrIEJxI8p1ioW1mZ",
"order_success_id":"iZUZ7fK0TH63t9viTqc4Wj0Q0MZOI8Qn","order_cancel_id":"ywMOIeQ99Q8XReTSd96jZcosHZE1Yeaz"}; Context: {
    "extra data": {
        "order_reference_id": "PdQXOoBF53wbAVYGfLzUvhCkOaQXqx5HZy_bidlZ9MgQtIkZJrIEJxI8p1ioW1mZ",
        "order_success_id": "iZUZ7fK0TH63t9viTqc4Wj0Q0MZOI8Qn",
        "order_cancel_id": "ywMOIeQ99Q8XReTSd96jZcosHZE1Yeaz"
    },
    "method": "app\\components\\services\\SessionUserService::writeSession",
    "file": "\/app\/components\/services\/SessionUserService.php",
    "line": 162
}

private function validateJsonData(array $jsonData): bool
	{
		$this->logDebug("validateJsonData called with keys: " . implode(', ', array_keys($jsonData)), [
			'json data keys' => implode(', ', array_keys($jsonData)),
		], 'validation');
		
		// TODO Define allowed keys for 'extra_data'.
		$allowedKeys = ['last_login_time', 'order_id', 'order_reference_id', 'order_success_id', 'order_canceled_id'];
		
		// Restrict the number of entries in 'extra_data'.
		if (count($jsonData) > 10)
		{
			$this->logDebug('extra_data exceeds maximum number of keys: ' . count($jsonData), [], 'validation');
			
			return false;
		}
		
		foreach ($jsonData as $key => $value)
		{
			// Reject unexpected keys strictly
			if (!is_string($key) || !in_array($key, $allowedKeys, true))
			{
				$this->logDebug("Invalid extra_data key found: {$key}", [
					'key' => $key,
				]);
				
				return false;
			}
			
			// Reject nested values (arrays/objects not allowed)
			if (is_array($value) || is_object($value))
			{
				$this->logDebug("extra_data value for key {$key} is a nested array/object which is not allowed.", [
					'value type' => gettype($value),
					'key' => $key,
				], 'validation');
				
				return false;
			}
			
			// Accept only string or int types
			if (!is_string($value) && !is_int($value))
			{
				$this->logDebug("Invalid type for extra_data key {$key}. Expected string or int, got " 
					. gettype($value), [
						'value type' => gettype($value),
						'key' => $key,
				], 'validation');

				
				return false;
			}
			
			// Validate string length.
			if (is_string($value) && mb_strlen($value) > 255)
			{
				$this->logDebug("Value for key {$key} exceeds max length of 255 chars.", [
					'value' => $value,
					'key' => $key,
				], 'validation');
				
				return false;
			}
		}
		
		/**
		* Optional: check total serialized length to prevent too large payload
		*/
		$encoded = json_encode($jsonData);
		
		if ($encoded === false || strlen($encoded) > 4096)
		{
			$this->logDebug('Encoded extra_data JSON too large or failed to encode: ' 
				. ($encoded === false ? 0 : strlen($encoded)), [
					'length' => $encoded === false ? 0 : strlen($encoded),
			], 'validation');
			
			return false;
		}//*/
		
		return true;
	}

trying to write:

$sessionData = $this->__sessionUser->readSession();
				
				if ($sessionData !== null)
				{
					$existingExtraData = $sessionData['extra_data'] ?? [];
					$newData = [
						'order_reference_id' => $orderReferenceId,
						'order_success_id' => $orderSuccessId,
						'order_cancel_id' => $orderCancelId,
					];
					$mergedExtraData = array_merge($existingExtraData, $newData);
					
					$this->__sessionUser->writeSession(['extra_data' => $mergedExtraData]);
				}
				
				var_dump($sessionData);die;