WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Setting A Redirect Cookie on WordPress (4 posts)

  1. sammiefields
    Member
    Posted 1 year ago #

    Hi all

    I've been searching on the net for a solution to my problem all day, but I can't make sense of anything I see, since I know absolutely NOTHING about coding.

    Here's what I'd like to do.

    1. I'd like to set a cookie when a person visits one particular page on my website, let's call it Page 1.
    2. Then, when that visitor goes to another unrelated page (Page 2), he/she gets automatically redirected to Page 3 (because of the cookie that was set when they visited Page 1). Visitors without the cookie, don't ever get to see Page 3.

    Is this doable?

    Oh, and by the way, I'm on a self-hosted WordPress site.

    Thanks so much.

    Sammie

  2. bcworkz
    Member
    Posted 1 year ago #

    This is possible, but it's not a simple "Add this short code snippet to functions.php" and everything will will work (AFAIK). You'll need someone with some coding experience, unless you are willing to put in the time and effort to learn a little PHP coding.

    The main functions involved are setcookie() and header(). The purpose of setcookie() is obvious, header() is used to alter the page location the browser is going to. These must be executed before any content is sent out to the client browser. This means a hook must be identified which can see which page is being requested and executes early enough that no content has yet been sent.

    The last paragraph probably makes no sense, but it's useful to whom ever is doing your coding. Or you may choose to study enough PHP until it makes sense to you. Good luck!

  3. sammiefields
    Member
    Posted 1 year ago #

    Thanks for your reply bcworkz. I can see you replied to my more recent post as well, so I'll discuss with you there ;)

  4. Andrew
    Forum Moderator
    Posted 1 year ago #

    Please stop duplicating the same thread.

Topic Closed

This topic has been closed to new replies.

About this Topic