Changed session management functions to use an active flag rather than a
special session value