Modified code to not store ghost session.