title: Cookies vs Session vs Database
body: <p>I have a website that customers can log into and buy products from a specific range (based on their customer number). The navbar has a dropdown for product categories, but doesn't show any where there would be no products.</p>
  
  <p>At the minute, the database is queried on each page to populate the product categories menu, but this feels inefficient. I'm now wondering if the list of 'allowed' products should be stored in either cookies or session variables at the beginning of a session.</p>
  
  <p>From what I have gathered from other questions, a session variable would normally be used, but they have warned against storing a lot of data in session variables. In this case, I would be storing a potentially large list of products for each user, so would cookies be better? I wouldn't class a list of products as being particularly sensitive, and I would do a server-side check before placing the order. Or should I stick with the current solution of querying the database each time?</p>
  
  <p>To be clear, I will still store the information in the database as well, this question is only asking about a temporary storage for quick access throughout the session.</p>
  
  <p>I have already looked at the following questions, but I still don't feel like I've quite got the answer for my particular scenario, and the questions that are close haven't mentioned cookies.</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/553185/cache-vs-session-vs-cookies">Cache VS Session VS cookies?</a></li>
  <li><a href="https://stackoverflow.com/questions/6253633/cookie-vs-session">Cookie VS Session</a></li>
  <li><a href="https://stackoverflow.com/questions/34870747/session-cookie-vs-persistent-cookie">Session Cookie vs Persistent Cookie</a></li>
  <li><a href="https://stackoverflow.com/questions/23496478/trade-off-between-user-data-in-session-vs-database">Trade off between user data in session vs database?</a></li>
  <li><a href="https://stackoverflow.com/questions/4217427/session-variables-vs-database">session variables vs database</a></li>
  </ul>