Jump to content

last viewed pages in cookie


gdfhghjdfghgfhf
Go to solution Solved by cyberRobot,

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
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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Solution

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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.