As soon as the CGI ends the output file, the HTTP server ends the reply to the HTTP client. This concludes an HTTP connection.
Yes, an HTTP connection only lasts from the request to the time the HTTP server replies. This means if Tak decides to order one of the books listed by the search feature, that opens a new HTTP connection! This makes it rather difficult to track sessions. We'll definitely come back to this topic later.