Fixed session-refresh detection function