does this mean that everytime the socket goes idle, the connection to the website closes?
The header 'Connection: close' tells the server to close the connection once it has finished sending you the file you've requested. This was the default behavior of HTTP/1.0, but HTTP/1.1 allows you to specitfy a 'Connection: Keep-Alive' that tells the server to leave the connection open for some time (usually a few seconds) so you can send further HTTP requests. This helps to speed up the retrieval of websites, because you can request everything (images, CSS, scripts) through one connection and don't have to open a separate connection for every file.
how do i remain logged in?
I'm afraid I can't tell you how until I see how the server works. If you can't publicize its address or login details for privacy reasons, can you please specify in more detail what you're sending, and what the serve replies are?