Support » Plugin: Ginger - EU Cookie Law » Shortcode Reset Cookie

  • raffdes

    (@raffdes)


    Qualcuno mi può spiegare come si usa lo shortcode Reset Cookie?
    A quale url bisogna linkare il bottone?
    Grazie

    Can someone explain to me how to use the Reset Cookie shortcode?
    Which URL should I link to?
    Thank you

Viewing 11 replies - 1 through 11 (of 11 total)
  • Put the shortcode to the cookie policy page 🙂
    The redirect link is useful only if you want to redirect the user to another page after the click.
    When you click the button it deletes all your domain generated cookies from the browser (but not the ginger-cookie).

    So since it doesn’t delete the Ginger cookie it doesn’t do what it should do.

    Use case: someone has visited my site and accepted cookies. He changes his mind, resets/deletes the cookies and continue browsing the site. Because it didn’t delete all the ginger cookie all cookies are saved again.

    How can this reset button problem be solved?
    [ginger_reset_cookie class=”” text=”” redirect_url=””]

    Thanks
    Cesare

    I’ve solved with this javascript (not mine, it’s a mix of stuff from various blog).

    <script>function deleteAllCookies(){for(var e=document.cookie.split(“;”),o=0;o<e.length;o++){var i=e[o],n=i.indexOf(“=”),t=n>-1?i.substr(0,n):i;document.cookie=t+”=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;domain=”,document.cookie=t+”=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;domain=”+location.hostname.replace(/^www\./i,””)}}</script>

    It deletes every cookie from your domain.

    Thanks!

    Excuse me where did you insert javascript? How does it work? Can you explain me better? Thank you

    Very quick & dirty… added a shortcode in the theme. But it could be very easy to create a plugin to do so, or insert javascript directly in the content (define( ‘CUSTOM_TAGS’, true ); and then put the button in code).

    add_shortcode('ge_delcookie', 'ge_delcookie');
    function ge_delcookie( $atts, $content = null ) {
    	$thesctipt='---script abobe---';
    	return $thesctipt.'<button class="" onclick="deleteAllCookies()">PRESS TO DEL COOKIES</button>' ;
    }

    have addedd in file function:

    add_shortcode(‘ge_delcookie’, ‘ge_delcookie’);
    function ge_delcookie( $atts, $content = null ) {
    $thesctipt='<script>function deleteAllCookies(){for(var e=document.cookie.split(“;”),o=0;o<e.length;o++){var i=e[o],n=i.indexOf(“=”),t=n>-1?i.substr(0,n):i;document.cookie=t+”=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;domain=”,document.cookie=t+”=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;domain=”+location.hostname.replace(/^www\./i,””)}}</script>’;
    return $thesctipt.'<button class=”” onclick=”deleteAllCookies()”>Delete Cookie</button>’ ;
    }

    Have added in privacy and cookie policy page: [ge_delcookie]

    but it does not work. Any suggestions?

    • This reply was modified 3 years, 8 months ago by Salentomane.

    Does the button shows up?

    Yes, button appears but nothing happens if I click

    You could check for js errors with the browser’s inspector…
    and try to run the code manually from the browser’s console.

    • This reply was modified 3 years, 8 months ago by xxxsimoxxx.
Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Shortcode Reset Cookie’ is closed to new replies.