working code for session listener