prevent possible race condition when storing a session value