Hello to all,
I hope all of you are healthy :) . I would like to ask if anyone has find a way to store recently viewed products in a cookie and not session. This requiest comes from a client that wants to be able to show recently viewed products for 5-10 days after a using comes back to site. The current function is to show the products until the session ends, after that it starts counting from zero.
the browsed products are added to the session in the shop function static public function addProductToRecent ($productId)
components\com_virtuemart\helpers\shopfunctionsf.php
I guess a plugin that stores that session object vmlastvisitedproductids to a cookie
Thanks GJC, I will try it and come back if needed.
Hello,
Happy new year to all. If I create a new function same to this but with the only difference that instead of session I will use cookie then how I can retrieve this cookie and show the products?
In addition, I have added the following in addProductToRecent function:
$inputCookie = JFactory::getApplication()->input->cookie;
$inputCookie->set($name = 'vmlastvisitedproductids_cookie', $value = $products_ids, time() + (86400 * 30));
but when I try to retrieve this cookie it does not exist. Does anyone have an idea of the reason?
$inputCookie = JFactory::getApplication()->input->cookie;
$inputCookie->set($name = 'vmlastvisitedproductids_cookie', $products_ids);
$inputCookie->getString('vmlastvisitedproductids_cookie');
see https://api.joomla.org/cms-3/classes/Joomla.Input.Cookie.html
I dont think that a timestamp can be set
You have to convert the cookie to a string and use getString()
Or if you set an array in the cookie use getArray()
Get without filters save a command (filter is az-_ only)
Thanks for the answer. I managed to create cookie but the expiration time is the same as the creation one and is marked as deleted! Can you help on this?
UPDATE: I am trying to modify "addProductToRecent" function and use cookie instead of session but nothing happens. It is like I never create the cookie...
please copy your code here.
I cannot know what you write wrong.