working with temporary table in cakephp 3 <p>I'm working in CakePHP 3.2</p> <p>I have a table <code>Carts</code> to store products in cart when user is logged in with <code>user_id</code>.</p> <p>I want addToCart accessible to user without login too. But in this case I want to use temporary table to store the cart data and when user is logged in, transfer all data from temporary table to <code>carts</code> table and delete <code>temporary table</code>.</p> <p>How to work with temporary table in CakePHP 3 ? Is it a good practice to use temporary data for the same or is there any better alternative to this ?</p> <blockquote> <p>Edit 2</p> </blockquote> <p>Values to store in cookie/temp table</p> <pre><code>product_id seller_id seller_product_id quantity </code></pre> <p><strong>Associations</strong></p> <p><code>product_id</code> is foreign key to <code>products</code> table <code>seller_id</code> is foreign key to <code>sellers</code> table <code>seller_product_id</code> is foreign key to <code>seller_products</code> table</p> <p>product table is further associated with <code>product_attributes</code></p> <p>Currently using <code>carts</code> table with following columns</p> <pre><code>+-----------+-------------+----------+---------------------+--------+ | user_id | product_id | seller_id | seller_product_id |quantity | +-----------+-------------+----------+---------------------+--------+ </code></pre> <p>and this is what I'm doing to retrieve associated data</p> <pre><code>if (!empty($this-&gt;Auth-&gt;user('id'))) { $user_id = $this-&gt;Auth-&gt;user('id'); $g_cart = $this-&gt;Carts-&gt;find('all', [ 'conditions' =&gt; [ 'user_id' =&gt; $user_id, ], 'contain' =&gt; [ 'Products', 'SellerProducts', 'Sellers', 'CartAttributes' ] ]); $g_count = $g_cart-&gt;count(); if (!empty($g_cart)) { // foreach($g_cart as $g_c){debug($g_c);} foreach($g_cart as $g_c) { $total_cost += $g_c-&gt;quantity * $g_c-&gt;seller_product-&gt;selling_price; } } } </code></pre> <p>Hope I'm clear to you.</p>