Add a helper function for managing sessions