禁用谷歌设置的cookie加一个按钮

Tsc*_*cka 6 cookies setting cookieless option

当我在我的网站上放置以下代码以获得一个不错的标准+1

<!-- Place this tag where you want the +1 button to render. -->
<div class="g-plusone"></div>

<!-- Place this tag after the last +1 button tag. -->
<script type="text/javascript">
  window.___gcfg = {lang: 'nl'};

  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>
Run Code Online (Sandbox Code Playgroud)

它做了我不想要的事情.

没有这个代码我只有我自己的phpsessid,这是我的网站运作所需要的.

使用此代码,将从域plusone.google.com中删除以下Cookie

谷歌加一个人丢了很多饼干!

现在,在查看2014年,2022年,2013年某个地方的到期日期......他们将会活很长时间.

重点是,文件随时可以访问如何通过谷歌+ 1按钮禁用cookie的放置,我已尽力看,甚至阅读了很多堆栈溢出帖子,希望找到相关的东西.

然而,我却发现了如何禁用分析的Cookie在我的追求(万岁!),但现在我需要找到一种方法,JavaScript的选项,或有事要告诉Plusone精选不要放置Cookie(万岁荷兰/欧洲cookielaw)

问题: 有没有人遇到过文件/选项告诉+1按钮不丢弃cookie?

Tsc*_*cka 0

我已经编写了一个基于权限的解决方法,但我仍然发现它远非理想,因为我必须在用户单击时向用户请求权限,但总比没有好。

我仍然需要一种方法来阻止谷歌删除不需要的cookie。在我看来,没有必要使用这么多 cookie 或根本没有任何 cookie 来跟踪用户。

此代码使用户单击该链接,当他们单击该链接时,系统会询问他们是否要显示该按钮以及该决定的后果是什么。

我的示例代码: http: //jsfiddle.net/CADjN/3/

现场演示 https://www.ortho.nl/orthomoleculaire-bibliotheek/artikel/8091/Langer-leven-met-vitamine-D

<script type="text/javascript"> 
// Function to set the cookie plusone.
function setCookie()
    {
    domain = "www.mysite.com";
    c_name="plusone";
    value="yes";
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + 365);
    var c_value=escape(value) + "; expires="+exdate.toUTCString()+';domain='+domain+';path=/';
    document.cookie=c_name + "=" + c_value;
    }
// Function to see if our plusone cookie exists and has value yes
// Returns true when the cookie is set, false if isn't set.
function getCookie()
    {
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++)
        {
        x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
        y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
        x=x.replace(/^\s+|\s+$/g,"");

        if (x.indexOf("plusone") != -1)
            {
        if(unescape(y)=="yes")
        {
        return true;
        }
    else
        {
        return false;
        }
        }
    }
}
// Load the plusone module but first ask permission
function loadplusone(thelink) 
    {   
    // Cookie hasn't been set
    if(!getCookie())
        {
            // Get permission
        if(window.confirm("If you wish to 'plusone' this page we need to load a special button from Google.com.\n\nWith this button Google will place some cookies on your computer. Google uses these cookies for statistics and maintaing your login status if you have logged in with Google.\n\nDo you consent to loading the button and the placement of cookies by Google?\n\nIf you agree this website will place a cookie with a year lifetime on your computer to remember this and the plusone button will be loaded on every page where the plusone button is present on this site."))
            {
                    // set cookie, load button
            setCookie();
            var jsnode = document.createElement('script');   
            jsnode.setAttribute('type','text/javascript');   
            jsnode.setAttribute('src','https://apis.google.com/js/plusone.js');   
            document.getElementsByTagName('head')[0].appendChild(jsnode);   
            document.getElementById(thelink).innerHTML = ''; 
            }
        }
    // cookie has already been set, just load button.
    else
        {
        var jsnode = document.createElement('script');   
        jsnode.setAttribute('type','text/javascript');   
        jsnode.setAttribute('src','https://apis.google.com/js/plusone.js');   
        document.getElementsByTagName('head')[0].appendChild(jsnode);   
        document.getElementById(thelink).innerHTML = ''; 
        }
    }
    </script>
    <!-- Where the plusone button should go this piece of code should be placed -->
    <a id="plus1" href="javascript:loadplusone('plus1')">Show Google +1</a><g:plusone></g:plusone>
    <!-- This should be placed below the above code or in the onload event of the document -->
    <script type="text/javascript">
    if(getCookie())
        {
        var jsnode = document.createElement('script');   
        jsnode.setAttribute('type','text/javascript');   
        jsnode.setAttribute('src','https://apis.google.com/js/plusone.js');   
        document.getElementsByTagName('head')[0].appendChild(jsnode);   
        document.getElementById('plus1').innerHTML = ''; 
        }
    </script>
Run Code Online (Sandbox Code Playgroud)