Use callback for session persistance

As per suggestion @benlovell @stevenwilkin