code: private void save(OutputStream os, String id, SessionData data) throws IOException {
          DataOutputStream out = new DataOutputStream(os);
          out.writeUTF(id);
          out.writeLong(data.getCreationTime());
          out.writeLong(data.getAccessedTime());
          out.writeLong(data.getLastAccessedTime());
          out.writeLong(data.getExpiryTime());
          out.writeLong(data.getMaxInactiveInterval());
  
          List<String> keys = new ArrayList<>(data.getKeys());
          out.writeInt(keys.size());
          ObjectOutputStream oos = new ObjectOutputStream(out);
          for (String name : keys) {
              oos.writeUTF(name);
              oos.writeObject(data.getAttribute(name));
          }
      }
docs: Save the session data.
  
  @param os the output stream to save to
  @param id identity of the session
  @param data the info of the session
  @throws IOException if an I/O error has occurred