• Hey Nick,

    Thank you very much for your work, first of all. What a wonderful plugin!

    I’ve set a code in my functions.php so a cookie is set when the URL contains a particular parameter. Now, I’ve found out that if the client is visiting my page with the parameter (example.com/?parameter=value) for the first time, they won’t see the block if it’s set to display only if the cookie is set.

    I verified this by creating the following (this is the expected result):

    • A: example.com –> no cookie set –> only display block0
    • B: example.com/?parameter=value1 –> cookie1 set –> only display block1
    • C: example.com/?parameter=value2 –> cookie2 set –> only display block2

    And this is what happens if I do these steps in this order:

    1. I visit B. The block from A is displayed.
    2. I visit C. The block from B is displayed.
    3. I visit A. The block from C is displayed.

    Can you think of something so it works correctly? I could use the query string check, but it’s not preserved in other pages unlike a cookie.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Nick Diego

    (@ndiego)

    Hi @sixaxis,

    I believe this is correct based on how cookies are set and blocks are rendered in WordPress.

    • When you visit B for the first time, the cookie is not yet set by the time the block renders, so A is displayed.
    • Then when you visit C, the B cookie is set from previously visiting B, but the C cookie has not yet been set. So you see B.
    • Then when you visit A, the C cookie has now been set so you see C.

    You might be able to use a combination of the Query String control and the Cookie control. The Query String would take effect when the cookie is not yet set, then the Cookie control will take over from there. You will need a way to reset the cookies depending on the query string parameter, if that is not already implemented.

    I hope that helps.

    Best,
    Nick

    Thread Starter Gerard Blanco

    (@sixaxis)

    Thanks, Nick 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Cookie check with edge case’ is closed to new replies.