Since you are relying on the URL parameter to set cookies, why not prioritize it over the cookie for the first page load?
At your second code block, changing the line $plan_cookie
to this might help.
$plan_cookie = isset($_GET['plan']) && !empty($_GET['plan']) ? $_GET['plan'] : (isset($_COOKIE['plan']) ? sanitize_text_field($_COOKIE['plan']) : '');
Related Posts:
- Set A Cookie To URL Parameter, Pass Cookie From Page To Page To Alter Post
- Why “?v=hash” is added to my URLs? [closed]
- use query string in URL to display content on the page
- Pulling a parameter out of the URL of a WP link without “?” or being sent to a different page
- Dynamically change page title from URL param
- 404 error when passing “cat” parameter to URL
- Check if user is logged in to site A when visiting site B
- How to add URL-Parameter for Javascript Widgets?
- HTTP 403 Error when passing parameters to URL
- WordPress get parameter ‘unapproved’ and ‘moderation-hash’
- How to parse a custom url (within WP site) and obtain params passed to that URL
- Passing values through url for checkbox fields with same name to get?
- Custom HTML title based on URL parameter
- How to get a page url segment on wordpress?
- Different url to same page (with dynamic content)
- Add a paramter to page url
- Why “?v=hash” is added to my URLs? [closed]
- Add more than one query parameter onto wordpress url
- Use URL parameter to create dynamic content
- Pass post title as URL parameter
- Let WordPress to go opening an external URL
- How to pass parameters thru URL?
- Duplicate pages with ?s parameter
- How to use query string in URL to display content on the wordpress page
- help me remove this additional parameter in url
- How do you retrieve a post by slug name through REST API?
- How does routing on wordpress work?
- Redirecting to old domain after migration
- Unwanted media library URLs in posts?
- How to remove file versions from the file source links in wp_head?
- Add menu and submenu in admin with a URL instead of slug?
- Update media file url in wordpress media library
- Change logo url link
- As soon as I add a custom query_var using the filter, my pages point to an archive page – why?
- Password protected page Hash url
- Remove site root trailing slash
- How to create a page for authors? like www.myblog.com/author/
- Old URL Redirect website after migration
- Best way to give site sub-page it’s own domain?
- What is the correct way to convert the absolute path of the executing script to a URL, in WordPress?
- Getting 404 Hits on URI -/-/-/-/-/-/-/-/-/- . How to deal
- Rewrite custom post type URL parameters
- How to change logo url [closed]
- Is it possible to configure WordPress’s Core Files to accept duplicate Child Categories?
- Make homepage a non-WordPress page
- Avoid the removal of “https:” from URLs
- Content duplication issue with dynamic URLs
- Is get_permalink also the canonical URL?
- Remove trailing slash from previous_posts_link()
- Moved WP into new folder. How to fix image links in posts?
- How do you make homepage redirect to it’s slashed version?
- Using esc_url_raw with protocols properly
- Change URLs depending on alias
- wordpress copyright dynamic
- Multiple duplicate URL’s
- Made WordPress URL and site address URL the same
- How can i get rid of wp in front of URL
- Dynamic URL and pass the data to an iframe
- DNS – Change WordPress Site Name?
- Unnecessary url
- How to close tab automatically if URL has specific word? [closed]
- Replace category name with article id in wordpress urls
- Finding URI in Child Theme
- Make custom system url
- Sanitizing URL in a WordPress plugin
- How to display translated content with custom slug?
- How to set wordpress url on local host to access it via VPN
- How to create a user ability to save pages with full url?
- Append a parametter at first or last to a certain URL
- how to remove this #.XsZOUWhKjIU from my wordpress url
- WordPress Website change directory
- Allow duplicate slugs for pages and posts
- Add addtional page parameter before loading the page
- How to encode correclty an url with the char “&” for an email?
- Change dynamically URL to SEO friendly via .htaccess?
- Get userdata from url
- How to make url variable?
- Change default query parameters
- WordPress dynamic subpage for ACF
- From whence %E2%80%8E at the end of post link
- WordPress Address (URL) Reverts back
- Get parameters and custom page template
- Redirect based on $_GET parameters
- problem getting audio url
- wp-login.php ampersand in url results in 404
- How to pass REQUEST_URI to function
- Change path/url of admin-bar.min.css
- wordpress url with format .com/category/sub-category
- Why is my WordPress install using full server directory paths for media URLs?
- Accidentally Changed WordPress Url
- Typing local WordPress URL works, but clicking the same link does not
- URL Forwarding – wordpress links reverting back
- Get gallery url (Nextgen) [closed]
- Function to get custom post image URL
- How to echo a dynamic url
- Block a specific url request
- WordPress rewrites my link with custom URL scheme to http(s)
- Show page name after home url
- how to add param string after website url in wordpress?
- Are the wp entries in these URL’s legitimate?