I have multiple PHP scripts on my site and they all have separate connections to my MySQL databases. I want an easy way to share the same connection across these scripts without leaving any connections open after the user has left the site.

I was thinking of using a session to carry the connection handle but the problem with this is if the user leaves the site, their database connection will remain open.

I have a high volume of users and can't mess around with leaving MySQL connections open & unused and I also don't want to have them keep opening and closing connections constantly... it's a waste of valuable system resources.

What is a good solution for this?