User macro to save state of checkboxes on macro save

Hi all,
I am developing a user macro which fetches some categories and creates a checkbox for those categories. But I am not able to save state of checkboxes on macro save and publishing page and fetch same on page open. Can anyone suggest what is the approach to persist checked elements in user macro.

Thanks,
Ashish