Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2018-07-06 09:45:19

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: oui_cookie - Set, read, reset or delete cookies

FYI, oui_cookie v1.0.0-BETA3 is released.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#14 2018-07-06 11:16:53

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

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

#15 2018-07-06 11:20:52

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

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.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

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

#17 2018-10-26 14:41:52

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

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)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

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 – or isSet in this case – is a reserved word in PHP. Replacing isSet occurences by isCookieSet fixes that.

Thank you! Plugin is work now :)

Offline

#19 2020-07-20 18:07:14

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

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

#20 2024-10-30 18:22:27

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

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

#21 2024-11-01 23:12:53

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

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

#22 2024-11-01 23:26:59

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

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

#23 2024-11-02 05:45:36

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

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

#24 2024-11-02 15:43:58

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

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

Board footer

Powered by FluxBB