title: How can I fetch a value from my database and display it across pages using cookies or similar?
body: <p>My website connects to a database of products which each have a unique part number assigned to them (as well as other details such as manufacturer and description).</p>
  
  <p><strong>For example:</strong> </p>
  
  <p>'Product A' might have a Part Number of '275'.</p>
  
  <p>'Product B' might have a Part Number of '608'.</p>
  
  <p><hr />
  Using a plugin created by our original developer, these part numbers are used to create a page for each product/part number variation automatically (everytime we add new products to the database).</p>
  
  <p><strong>For example:</strong> </p>
  
  <p>Part Number '275' creates www.mydomain.com/producta/275</p>
  
  <p>Part Number '608' creates www.mydomain.com/productb/608</p>
  
  <p>Each new page is essentially a templated page that adds the product name and part number (as well as manufacturer and description) to various places within a generic product page.</p>
  
  <p>So to retrieve the information from the database and place it into the templated page, we connect to the database and call the product name, part number, manufacturer and description using:</p>
  
  <pre><code>$prod = $item['product_name'];
  $pn = $item['part_number'];
  $man = $item['manufacturer'];
  $desc = $item['description'];
  </code></pre>
  
  <p><strong>What I need</strong>
  <p>I would like to create a button such as 'Add to quote' that automatically takes the value of the part number ($pn) from the product page that the user is on and adds it to a form field on another page called My Quote.
  <p>The important thing is that not only does the value transfer over to the 'My Quote' page., but that the 'My Quote' page stores the value of the field so that the user can then go to another product page and repeat the process and essentially build a list of parts that they require.</p>
  
  <p><p>I have looked at somehow utilising cookies for this, by somehow setting the value of the cookie as a variable based on the value of the $pn but I don't think that's possible:</p>
  
  <pre><code>Cookies.set("partnumber", "//code here to read the $pn of the page and set as the cookie value", { expires: 7 });
  </code></pre>
  
  <p>I know the above is not correct, but I wonder if there is a way to replace '$pn' with something to read the part number of the page the user is on, then save the cookie on 'Add to Quote' button click and read and display the cookie value within the field on the 'My Quote' form page?</p>
  
  <p>Cookies may not be the way to go so I would appreciate any other ideas. I am farily new to this so apologies in advance for any poor formatting of my question.</p>