humans_21909=1 error in codeigniter project

2020-02-14 08:34发布

问题:

Some controller functions in codeigniter is setting up humans_21909 cookie. And the page source appears to be as follows

<script>document.cookie = "humans_21909=1"; document.location.reload(true)</script>

The same project worls perfectly on local server. but on live server it shows this stuff.

回答1:

This is a network related issue. I just switched my internet connection to different wifi and it works fine. Don't know more about this error but it solved by this way.



回答2:

Once I degraded the PHP version, the error has gone. May be because codeigniter deperciated syntax or some other features in the new version. Thanks



回答3:

I have found that issue is coming from cookie. Please set a cookie in header.php file with project path in this after set of cookies page will reload without changing web URL

e.g

<script type="text/javascript">
function getCookie(name) {
  var value = "; " + document.cookie;
  var parts = value.split("; " + name + "=");
  if (parts.length == 2) return parts.pop().split(";").shift();
}
var accept = getCookie("humans_21909"); 
if (accept !="1") {
document.cookie = "humans_21909=1; path=/insert here project root path/"; 
    console.log("ok"); 
    (function()
    {
      if( window.localStorage )
      {
        if( !localStorage.getItem('firstLoad') )
        {
            console.log("refresh");
            localStorage['firstLoad'] = true;
            window.location.reload();
        }  
        else
          localStorage.removeItem('firstLoad');
      }
    })();
}

I think your issue with resolve with this