Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Pure JS Help with Cookie Tool Re: Pure JS Help with Cookie Tool

#102102
chrisjg
Member

Add
document.cookie =
‘stupid-eu-law=accept-cookies; expires=Mon, 31 Dec 2525 23:59:59 UTC; path=/’;

into the onclick property of the button, eg:

onclick=”setVisibility(‘cookies-notify’, ‘none’);document.cookie =
‘stupid-eu-law=accept-cookies; expires=Mon, 31 Dec 2525 23:59:59 UTC; path=/’;”

it will set the following cookie:
Name: stupid-eu-law
Content: accept-cookies
Domain: fiddle.jshell.net
Path: /
Send for: Any kind of connection
Accessible to script: Yes
Created: Tuesday, 1 May 2012 20:09:15
Expires: Monday, 31 December 2525 23:59:59

the Created date will change, but the rest is fixed

See http://jsfiddle.net/xq6XX/9/

if you want some useful js cookie functions check out http://jsfiddle.net/chrisjg/bbVuq/1/

I have used these for a long time, in many places. They are pretty standard ways of writing, reading and deleting cookies in js. Hope you find them useful, and/or learn from them.

Chris.