getDeviceID function

String getDeviceID()

Main function to get or create a device ID

Implementation

String getDeviceID() {
  String? deviceId = getCookie("deviceId");
  if (deviceId == null) {
    deviceId = generateUUID(); // Generate a UUID
    setCookie("deviceId", deviceId, 365); // Cookie expires in 365 days
  }
  return deviceId;
}