I’m have a code show another product was seen in single product page.
my idea : save id of posts to array by session:

Then using loop or foreach to show title, img, link …etc…

MY CODE

session_start();

    $_SESSION['id'] = get_the_ID();
     $cart = array (
        'id' => $_SESSION['id'],
    );

    $_SESSION['cart'][] = $cart; // array id

But, when user closed browser. all data not save.
And i want convert session to Cookie to save for one month.
How to change for the right ways.
Please help to the idea for this Solution .

Thankyou all.

Read more here: convert array product was seen by user from session to cookie in php


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: