Jump to content

last viewed pages in cookie


gdfhghjdfghgfhf

Recommended Posts

I have very little experience with cookies so i don't know how to do that

 

I have a t-shirt shop where each t-shirt has an $articleID

 

Each time an user visits a t-shirt page, i would like to add the $articleID to a cookie. Add it to an array or something so i can retrieve it later.

 

Then on the main page, i want to retrieve the list of the last 5 $articleID visited and display a list of the ID

 

How could i do that ?

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/275298-last-viewed-pages-in-cookie/
Share on other sites

If you're looking to retrieve the article IDs as the visitor is looking around the website, you could consider using a PHP session:

http://www.php.net/manual/en/intro.session.php

 

If you're looking to retrieve those article IDs after the visitor leaves the website and comes back a couple days later, for example, you could consider cookies:

http://php.net/manual/en/features.cookies.php

Yeah i would need cookies since i want to track even if the visitor leave the website.

 

So i have an $articleid on each pages, how could i put it in an array or something each time a page is visited, and then retrieve the list of $articleid ?

 

I have really no experience with cookies, i dont know how to do that

Did you get a chance to look at the link mentioned earlier?

http://php.net/manual/en/features.cookies.php

 

More information about setting cookies can be found here:

http://www.php.net/manual/en/function.setcookie.php

 

 

There are also many articles available online for setting cookies with PHP such as this one:

http://davidwalsh.name/php-cookies

 

Or you could try Google:

https://www.google.com/search?q=create+a+cookie+with+php

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.