Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: oui_cookie - Set, read, reset or delete cookies
jakob wrote #338111:
I also tried the delete mechanism: if you add this to the code above:
<txp:variable name="delete" value='<txp:page_url type="delete" />' />...
…it does successfully delete the cookie in the web inspector view.
I tried this but the link (<txp:permlink />?lang=&delete=1
) does not appear to be deleting the cookie.
What I am attempting is to create a shortcode to allow visitors to delete cookies. As we are also using other ones, these are the two methods I am trying without success.
<txp:oui_if_cookie name='<txp:yield name="cookie" />'>
<txp:variable name="lang" value='<txp:page_url type=''<txp:yield name="cookie" />'' />' />
<txp:variable name="delete" value='<txp:page_url type="delete" />' />
<a href="<txp:permlink />?lang=<txp:variable name='<txp:yield name="cookie" />' />&delete=1">Delete cookie</a>
<txp:if_variable name="delete" value="1">
<txp:oui_cookie name='<txp:yield name="cookie" />' delete />
</txp:if_variable>
<txp:else />
<txp:yield name="life" />
</txp:oui_if_cookie>
and
<txp:oui_if_cookie name='<txp:yield name="cookie" />'>
<txp:variable name='<txp:yield name="cookie" />'><txp:php> echo gps('<txp:yield name="cookie" />'); </txp:php></txp:variable>
<txp:if_variable name='<txp:yield name="cookie" />' value="delete" match="exact">
<a rel="nofollow noindex noodp noydir noarchive nocache" href="?<txp:yield name="cookie" />=delete">Delete cookie</a>
<txp:oui_cookie name='<txp:yield name="cookie" />' delete />
</txp:if_variable>
<txp:else />
<txp:yield name="life" />
</txp:oui_if_cookie>
And the shortcode: <txp::delete_cookie life="30 minutes" cookie="some_cookie" />
SOLVED
Here’s the working code
<txp:oui_if_cookie name='<txp:yield name="cookie" />'>
<a rel="nofollow noindex noodp noydir noarchive nocache" href="?delete_cookie=<txp:yield name="cookie" />">Delete cookie</a>
<txp:variable name="delete_cookie" value='<txp:php> echo gps("delete_cookie"); </txp:php>' />
<txp:if_variable name="delete_cookie" value='<txp:yield name="cookie" />' match="exact">
<txp:oui_cookie name='<txp:yield name="cookie" />' delete />
</txp:if_variable>
<txp:else />
<txp:yield name="life" />
</txp:oui_if_cookie>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline