Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-05-26 13:58:12

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

oui_cookie - Set, read, reset or delete cookies

Documentation & download

Examples
Manual cookie setting
<txp:oui_cookie name="favourite_fruit" value="apricot" />
<txp:oui_cookie name="favourite_fruit">
    My favourite fruit is the apricot.
</txp:oui_cookie>
Cookie setting through a fruits HTTP variable
<txp:oui_cookie name="fruits" values="apple, pear, apricot" />

Then call an url like http://my-website.com/?fruits=apricot.
You can also add a default value here.

Reading
<txp:oui_cookie name="favourite_fruit" />
Deletion
<txp:oui_cookie name="favourite_fruit" delete="1" />
Cookie checking
<txp:oui_if_cookie name="favourite_fruit">
    My favourite fruit is the <txp:oui_cookie name="favourite_fruit" />.
<txp:else />
    I don't have any favourite fruit.
</txp:oui_cookie>

You can also add a value to check against the cookie value here.

Last edited by NicolasGraph (2016-06-22 06:34:31)


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

Offline

#2 2016-05-28 13:55:42

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

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

I updated the github documentation for clarity. Updates will be included in the next release.


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

Offline

#3 2016-05-29 11:10:31

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

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

oui_cookie v.0.1.3 is ready to go…


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

Offline

#4 2016-06-21 07:17:10

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

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

oui_cookie v.0.2.3 includes important changes; please, check the first post of this thread or the plugin documentation.


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

Offline

#5 2018-06-10 06:54:42

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

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

Hi Nicolas,

I am making heavy use of your plugin (v: 1.0.0-beta2) which has become indispensable following the EU laws but I have a a couple of questions.

  1. Could you please let us know how the duration attribute should be used? ie is this the right format? duration="+1 year"
  2. Is there a way to make this plugin compatible for Textpattern version: 4.4.1 running on PHP version: 5.4.45? I have edited the first part by adding if(class_exists('\Textpattern\Tag\Registry')) { which prevents txp from crashing but clicking the Accept link in the front end, the cookie warning does not disappear and the analytics do not load. Sample url: news.neme.org/1824/state-machines.

Many thanks


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2018-06-10 08:56:09

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

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

colak wrote #312487:

Hi Yiannis,

Could you please let us know how the duration attribute should be used? ie is this the right format? duration="+1 year"

It will accept anything the php function strtotime accepts – see the docs – so it should accept #1 year.

but clicking the Accept link in the front end, the cookie warning does not disappear and the analytics do not load. Sample url: news.neme.org/1824/state-machines.

When I load that page the first time, the inspector shows only the piwik cookie to start with. If I click accept I see the accept cookie and the google analytics cookies. But, as you say, the banner doesn’t disappear.
But If I don’t click accept but refresh the page I still get the google analytics cookies, which if you’re doing explicit opt-in, I shouldn’t get until I really click accept.

Is there a way to make this plugin compatible for Textpattern version: 4.4.1 running on PHP version: 5.4.45? I have edited the first part by adding if(class_exists('\Textpattern\Tag\Registry')) { which prevents txp from crashing

Good catch. You might also want to put in some debug values into your code to check what the cookie state is so you can see if the tests are working. It is weird that you are getting both the message and google analytics. As far as I can tell from your cookies form code, it should be one or the other, but I haven’t looked in detail.


TXP Builders – finely-crafted code, design and txp

Offline

#7 2018-06-10 09:28:16

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

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

Hi Julian
Debugging is a good idea! This is what I basically have:

<txp:oui_cookie name="accept_cookies" duration="+1 year" values="yes" />
<txp:oui_if_cookie name="accept_cookies">
<txp:rvm_if_privileged>
<txp:else />
analytics js scripts
</txp:rvm_if_privileged>
<txp:else />
disclaimer <a rel="nofollow" href="?accept_cookies=yes">Accept</a>
</txp:oui_if_cookie>

and this is the tag trace in debug mode!

<txp:output_form form="google_anal" />
			[SQL (0.00018095970153809): select Form from txp_form where name='google_anal']
			[Form: google_anal]
			<txp:oui_cookie name="accept_cookies" duration="+1 year" values="yes" />
			<txp:oui_if_cookie name="accept_cookies">
				<txp:rvm_if_privileged>
					[<txp:rvm_if_privileged>: true]
				</txp:rvm_if_privileged>
				<txp:else />
					Tag error: <txp:else /> -> Textpattern Warning: tag does not exist while parsing form <strong>google_anal</strong> on page <strong>default</strong> (edit: this is where the cookie disclaimer goes)
			</txp:oui_if_cookie>

This is the tag trace on the page when I am not logged in

		<txp:output_form form="google_anal" />
			[SQL (0.00022101402282715): select Form from txp_form where name='google_anal']
			[Form: google_anal]
			<txp:oui_cookie name="accept_cookies" duration="+1 year" values="yes" />
			<txp:oui_if_cookie name="accept_cookies">
				<txp:else />
					Tag error: <txp:else /> -> Textpattern Warning: tag does not exist while parsing form <strong>google_anal</strong> on page <strong>default</strong>
			</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

#8 2018-06-11 07:36:39

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

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

Hi colak, and jakob, I should have some time to take a look today. I’ll come back to you. Thanks.


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

Offline

#9 2018-06-11 08:06:05

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

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

colak, I can’t make Txp 4.4.1 work for now but I know that there is at least one more thing that should be changed in oui_cookie to make it work with lower versions than v4.6. It is about the parser here. Could you try to add evalelse like so return parse(evalelse($thing, $out)); and let me know how does it help?


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

Offline

#10 2018-06-11 09:33:28

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

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

Hi Nicolas,

The evalelse seems to have done the trick! Now the boxes appear as they should and hide on accept. I’ll also be checking if anything loads this afternoon and let you know. Many many thanks!!!


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#11 2018-06-11 11:22:27

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

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

colak wrote #312505:

The evalelse seems to have done the trick! […]

Glad it helped; I hope everything will be alright now.


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

Offline

#12 2018-06-11 14:52:24

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

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

NicolasGraph wrote #312506:

Glad it helped; I hope everything will be alright now.

Indeed it is. I checked it in 3 browsers and all is working as intended.


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