My website has a database of products which each have a unique part number.
I have recently created a cookie on my website, which is called 'partnumber' and has a value of the part number that is assigned to it from my database.
This is the code that I have currently and is producing a cookie with the value of whichever part number is assigned to the product page I am on:
<script type="text/javascript">
<?php
// LOAD REQUIRED WP PLUGIN class
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// DO PLUGIN ACTIVATION CHECK
if ( is_plugin_active('product-item-templates/product-item-templates.php') ) {
// Product Items Template is LOADED >>
?>
<?php
$item = $new_url->get_page_url_data();
$pn = $item['pn'];
$man = $item['man'];
$model = $item['model'];
?>
var pn = "<?php echo $pn;?>";
var model = "<?php echo $model;?>";
var man = "<?php echo $man;?>";
Cookies.set("partnumber", pn , { expires: 7 });
<?php
} // END PLUGIN ACTIVATED CHECK
?>
</script>
So for example, if a user visits the product page with the part number 'ABC', then the cookie with the name: 'partnumber' saves with a value of 'ABC'.
The reason I wanted to do this was to be able to trigger the cookie with a button called 'Add to quote' which would then call the value of the cookie into a seperate field within a 'My Quote' page. However, each time I visit a new part number page, the cookie simply replaces the value of the 'partnumber' cookie with the new value.
My question:
Is it possible to save multiple values of the same cookie? Or say up to 10 values of the same cookie?
If not, could anyone please help with an alternative way of saving this unique information and displaying it on another page, so that a user can browse my products, click the 'Add to quote' button and then go to a 'My Quote' page to see the list of part numbers they have added to the quote.
Note: I know how to set a value to a cookie, but I want to know how to set mutiple different values to the same cookie - or alternatively, how to tell the site to create a new cookie with a different value (that is existing and comes from my product database) each time I click a button on my site.
Thanks in advance.