title: Connections to MySQL database
body: <p>Possibly a dummy question, but I can't figure it out. It's a concept question.
  I have a web platform where users store a lot of things with around 500 simultaneous connections.
  In term of performance / security, what is the best approach :</p>
  
  <ul>
  <li>Connect the user to the DB each time I need to grab data from it (every time he goes to another page BTW) and close the connection after I grabbed them ?
  Or </li>
  <li>Connect the user ONCE to the DB at login, keep the link to the DB (like in $_SESSION) and kill the connection at logout ?
  Or</li>
  <li>At login, grab almost everything from the user table, its profiles one and all the other ones, put them in $_SESSION and only connect to DB when update/insert are needed ? </li>
  </ul>
  
  <p>The connection itself is time consuming that's why I'm looking for the best approach.
  But on the other hand, I've always heard "always close your database connection as soon as possible"</p>
  
  <p>Thanks for your help.</p>