wordpress, category redirect using cookies

What I want to achieve:
When a person comes to the site and selects a particular category, the next time they come to the site (returning user) – the page will open up on that category section.

I would think this would be fairly easy to do via setting a cookie when the visitor clicks on the category link (or when the category page loads). When they return the following time, the cookie is read and then the page redirects accordingly.

Read More

Unfortunately my knowledge of PHP and cookies is limited, (hence my search for answers) so I need to ask if anyone can help me out!

Anyone have any ideas?

Thanks!

Related posts

Leave a Reply

2 comments

  1. The first thing you need to do is set the cookie for the category so each time you are displaying the category page you want to run code like the following:

      <?php
        $expire=time()+60*60*24*30;
        setcookie("cat", "/cat1", $expire);
      ?>
    

    Then when a user hits your home page you want to check if that cookie is set.

    <?php
       if (isset($_COOKIE["cat"]))
       {
           //Redirect to that page stored in the cookie
           $_COOKIE["cat"]; //Theres what you need you can handle the redirect how you like
       }
    ?>