Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: oui_cookie - Set, read, reset or delete cookies
FYI, oui_cookie v1.0.0-BETA3 is released.
Offline
Re: oui_cookie - Set, read, reset or delete cookies
Hi Nicolas
On the surface, it all looks like it is working just fine. I’ll start experimenting with the delete cookie function next week.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: oui_cookie - Set, read, reset or delete cookies
colak wrote #312879:
[…] On the surface, it all looks like it is working just fine. I’ll start experimenting with the delete cookie function next week.
Nice, thanks. Freel free to come back to me if you have any question or suggestion.
Offline
#16 2018-10-26 12:51:18
- ENB
- New Member
- Registered: 2016-10-04
- Posts: 5
Re: oui_cookie - Set, read, reset or delete cookies
Hello. Help me, please
After installation plugin (txp 4.7.1, plugin Beta3) I have this error:
Parse error: syntax error, unexpected ‘isSet’ (T_ISSET), expecting identifier (T_STRING) in …\lib\txplib_misc.php(1826) : eval()’d code on line 199
plugin_load_error_aboveoui_cookie
On local server and VPS
Is there any solution to this problem? Thanks for any info
Offline
Re: oui_cookie - Set, read, reset or delete cookies
ENB wrote #314745:
Hello. Help me, please
After installation plugin (txp 4.7.1, plugin Beta3) I have this error:Parse error: syntax error, unexpected ‘isSet’ (T_ISSET), expecting identifier (T_STRING) in …\lib\txplib_misc.php(1826) : eval()’d code on line 199
plugin_load_error_aboveoui_cookie
Hi, isset
– or isSet
in this case – is a reserved word in PHP. Replacing isSet
occurences by isCookieSet
fixes that. I’ll commit soon I compiled a new pre-release here ; thanks for the report.
Last edited by NicolasGraph (2018-10-26 14:53:46)
Offline
#18 2018-10-27 07:47:30
- ENB
- New Member
- Registered: 2016-10-04
- Posts: 5
Re: oui_cookie - Set, read, reset or delete cookies
NicolasGraph wrote #314752:
Hi,
isset
– orisSet
in this case – is a reserved word in PHP. ReplacingisSet
occurences byisCookieSet
fixes that.
Thank you! Plugin is work now :)
Offline
Re: oui_cookie - Set, read, reset or delete cookies
Hi Nicolas,
Can you please shed some light on how to include a delete cookie link? Should it be ?cookie_name&delete=1
?
Also, is there a way to delete all oui cookies?
I know how to do it in the browser but I’m also trying to give an easy option to the visitors.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: oui_cookie - Set, read, reset or delete cookies
I am most probably missing something but the cookie I am creating does not delete itself even when the duration is 30’.
the code, with many thanks to kuopassa
<txp:variable name="lang" value='<txp:php> echo gps("lang"); </txp:php>' />
<txp:if_variable name="lang" value="el" match="exact">
<txp:oui_cookie name="lang" duration="30 minutes" value="el" />
<div lang="el">
p>. ==<a lang="en" rel="nofollow noindex noodp noydir noarchive nocache" href="<txp:permlink />?lang=en">Read the original English text.</a>==
Λορεμ ιπσθμ δολορ σιτ αμετ, qθι εα πθρτο προμπτα δελεcτθσ cθ.
</div>
<txp:else />
<txp:oui_cookie name="lang" duration="30 minutes" value="en" />
p>. ==<a rel="nofollow noindex noodp noydir noarchive nocache" href="<txp:permlink />?lang=el">Διαβάστε μετάφραση του άρθρου στα Ελληνικά.</a>==
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</txp:if_variable>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: oui_cookie - Set, read, reset or delete cookies
Hi Yiannis,
I tried this out with a slightly simplified version of your code, and using the most recent code from oui_cookie. For this I downloaded the installer from the GitHub repo (which is a bit out of date), then downloaded the current versions of oui_cookie.php and manifest.json from the repository and copied them over the files in the /textpattern/plugins/oui_cookie/
directory, then under Admin › Plugins reloaded the plugin from disk.
I made a form with the following which I then included in the header of the standard template:
<txp:variable name="lang" value='<txp:page_url type="lang" />' />
<div class="lang-switcher">
<txp:if_variable name="lang" value="el">
<txp:oui_cookie name="lang" duration="+30 minutes" value="el" />
<txp:variable name="lang" wraptag="lang: <+>" />
<a href="<txp:permlink />?lang=en">Switch to English.</a>
<txp:else />
<txp:oui_cookie name="lang" duration="+30 minutes" value="en" />
<txp:variable name="lang" wraptag="lang: <+>" />
<a href="<txp:permlink />?lang=el">μεταβείτε στα ελληνικά.</a>
</txp:if_variable>
</div>
In the browser web inspector I can see the lang
cookie with the respective language code as the value. The expiry date gets reset to 30 minutes from the current page refresh time.
the cookie I am creating does not delete itself even when the duration is 30’.
How are you checking this? If you refresh the web inspector using COMMAND + R, it will also reload the page in the browser, causing your code to run and in turn to refresh the cookie. In effect, your cookie will expire properly, but when you try to view its status, you inadvertently refresh it, so it looks like it never expired.
In the web inspector in Safari, there are a few icons at the top-right of the Storage tab: a waste bin and a refresh icon. If you use that to refresh just that pane of the web inspector, the web page is not reloaded. I tried the above code but with a +2 minute
duration and the cookie does indeed expire properly after two minutes.
TXP Builders – finely-crafted code, design and txp
Offline
Re: oui_cookie - Set, read, reset or delete cookies
I also tried the delete mechanism: if you add this to the code above:
<txp:variable name="delete" value='<txp:page_url type="delete" />' />
<a href="<txp:permlink />?lang=<txp:variable name="lang" />&delete=1">Delete cookie</a>
<txp:if_variable name="delete" value="1">
<txp:oui_cookie name="lang" delete />
</txp:if_variable>
…it does successfully delete the cookie in the web inspector view.
TXP Builders – finely-crafted code, design and txp
Offline
Re: oui_cookie - Set, read, reset or delete cookies
jakob wrote #338110:
If you refresh the web inspector using COMMAND + R, it will also reload the page in the browser, causing your code to run and in turn to refresh the cookie. In effect, your cookie will expire properly, but when you try to view its status, you inadvertently refresh it, so it looks like it never expired.
Hi Julian,
Thanks so much for your input.
That’s probably the reason.
I think I solved it by deleting the ?lang=en
urls as they were superfluous and produced duplicated content, and adding <txp:oui_cookie name="lang" delete />
in the permlink
of the articles.
<txp:variable name="lang" value='<txp:php> echo gps("lang"); </txp:php>' />
<txp:if_variable name="lang" value="el" match="exact">
<txp:oui_cookie name="lang" duration="30 minutes" value="el" />
<div lang="el">
<a lang="en" rel="bookmark" href="<txp:permlink />">English.</a>
</div>
<txp:else />
<a lang="el" href="<txp:permlink />?lang=el">Ελληνικά.</a>
<txp:oui_if_cookie name="lang">
<txp:oui_cookie name="lang" delete />
</txp:oui_if_cookie>
</txp:if_variable>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: oui_cookie - Set, read, reset or delete cookies
colak wrote #338088:
I am most probably missing something but the cookie I am creating does not delete itself even when the duration is 30’.
This is solved! The issue persisted because Firefox does not automatically delete expired cookies.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline