Cookie check with edge case

[ad_1]

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!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer