code: static public String userToCookieString(boolean loggedIn, User user) throws Exception {
  		JSONObject cookieObj = new JSONObject();
  		
  		cookieObj.put("logged", loggedIn);
  		
  		JSONObject userObj = user.toJSON();
  		cookieObj.put("user", userObj);
  		
  		StringWriter sw = new StringWriter();
  		cookieObj.write(sw);
  		String cookieRaw = sw.toString();
  		
  		String cookieStr = URLEncoder.encode(cookieRaw,"UTF-8");
  		cookieStr = cookieStr.replace("+", "%20");
  		
  		return cookieStr;
  	}
docs: Converts an instance of User to JSON object, fit for a cookie
  @param user Instance of User to convert
  @return JSON string containing the user state
  @throws Exception