Hello,
I am wanting to have a prompt on my webpage load that asks the user if they allow the use of cookies, this is in line with new european directives that are due to come into force.
Once I get the user permission that is when I want the cookie to be set. I have the code to create the cookie and set the expiry on it to be 2 years:
My code for google analytics is in the page footer, can anyone help with an if statement around the analytics code, which looks to see if the cookie 'websitecookie' has been created then allow the analytics cookies, otherwise do not allow the google analytics cookies to be created.
thank you.
I am wanting to have a prompt on my webpage load that asks the user if they allow the use of cookies, this is in line with new european directives that are due to come into force.
Once I get the user permission that is when I want the cookie to be set. I have the code to create the cookie and set the expiry on it to be 2 years:
Code:
<script type="text/javascript">
Set_Cookie( 'websitecookie', 'cookiecreated', 730, '/', '', '' )
{
var today = new Date();
today.setTime( today.getTime() );
if ( expires )
{
expires = expires 730*24*60*60000;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
</script>
My code for google analytics is in the page footer, can anyone help with an if statement around the analytics code, which looks to see if the cookie 'websitecookie' has been created then allow the analytics cookies, otherwise do not allow the google analytics cookies to be created.
thank you.