I'm creating a IMAP/POP3 web client. Originally I planned to do it in PHP using the imap library however I'm worried about efficiency.
When the inbox page is loaded the PHP script connects and authenticates to the imap server, and then fetches an overview of the most recent emails. Once the page is done loading the php script ends and the connection to the imap server is lost.
This is a problem because any new action the user requests (such as a reading or deleting an email) has to go through the connecting/authentication process all over again. This slows it down considerably.
Is there anyway to preserve the connection to the imap server across page loads? Ideally I would like to do this in PHP but I'm open to using other technologies.