Hello, I installed cookieJar, and it is working correctly setting a custom cookie, but I have to do a manual refresh on my page in order to get the correct value for getCookie. Here is what I am doing:
I am working on displaying different content on my page depending on what location a user is coming from, so in my head I have:
[[!setCookie? &name=`cookie_market` &value=`[[*cookie_market]]` &expires=`2592000` &path=`/`]]
([[*cookie_market]] is a value set by a geoIP service)
I have a dropdown menu chunk to select a location:
<div class="select-location">
<div class="selected"><a href="[[*cookie_market]]/">[[!menuPlaceholder]]</a></div>
<div class="pulldown">
[[Wayfinder? &startId=`0` &level=`1` &limit=`6`]]
</div>
</div>
I have a snippet called menuPlaceholder that sets the value for the selected item in my dropdown options:
<?php
switch (($_COOKIE['cookie_market'])) {
case "new-orleans":
return 'New Orleans';
break;
case "st-louis":
return 'St. Louis';
break;
}
I also have getCookie set up on my logo, which is also not refreshing when I switch between markets:
<a href="[[!getCookie? &name=`cookie_market`]]" class="logo"><img src="assets/images/logo.svg"></a>
The issue happens when I switch between markets, inspecting the page I can see that my cookie is being set correctly for the new market, however, my placeholder text is either blank or displays the old value and the logo links to the old location. When I manually refresh the page, then the logo link and display name show correctly.
I added the ! to not cache my snippet and get/setCookie, but that doesn't seem to be working, can someone please help me with any suggestions on how to update my page values without having to do a manual refresh. Thank you very much.