How to use Cookies in Internet Explorer?

0

I am trying to store cookies for an application I developed in PHP and noticed that in Internet Explorer my cookies are not being stored (or are expiring soon after their creation). In my code I set Cookies this way:

setcookie("login", $login_confirmacao, time() + 3600, "/");
setcookie("senha", $senha_confirmacao, time() + 3600, "/");

I noticed that by disabling this function, the browser stored Cookies:

  

[] Block third-party cookies that do not have a compact privacy policy.

How can I set this "Compact privacy policy"? or how do I use cookies in IE?

    
asked by anonymous 30.01.2014 / 12:49

3 answers

1

IE does not trust cookies coming from iframes that do not have privacy policy (p3p).

Then you would have to make an XML file that identifies your privacy policy. That would be the compact version. To do it right you would have to create a full version as well, but the only reference I found is for paid generators.

Reference: link

Example:

<META>
  <POLICY-REFERENCES>
    <POLICY-REF about="/url-da-politica-de-privacidade/p3p.xml">
      <INCLUDE>/</INCLUDE>
      <COOKIE-INCLUDE/>
    </POLICY-REF>
  </POLICY-REFERENCES>
</META>

Within the INCLUDE tag you put what parts of your site this privacy policy cover in case "/" is everything.

Then in PHP you would have to put the headers according to your privacy policy, if you are only testing you can only use the headers, but if you go into production you should do the other steps:

Example:

header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');

Each such acronym represents a type of behavior regarding user privacy on the part of your site.

A complete list: link

    
30.01.2014 / 13:28
2

If you want to handle cookies in IE with JavaScript, a good approach would be to use lib: JqueryCookie

The use itself is quite simple:

Store: $.cookie('variavel_nome', 'valor');

Read: $.cookie('variavel_nome');

Delete: $.removeCookie('variavel_nome');

    
30.01.2014 / 13:10
0

I do not understand your question, but if you want to add a cookie , this should work:

<script language="JavaScript">
<!--
letterTable='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMabcdefghijklmnopqrstuvwxyzabcdefghijklm';
function rot13(str) {
 var outStr='';
 for (var k=0;k<str.length;k++) {
  var ch=str.charAt(k);
  var ix=letterTable.indexOf(ch);
  outStr+= (ix==-1) ? ch : letterTable.charAt(ix+13) ;
 }
 return outStr;
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}
//-->
</script>

<pre>
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}
</pre>

Form:

<form name="setCookie">
<table border=0 cellpadding=3 cellspacing=3>
<tr><td>Nome do Cookie:&nbsp;
</td><td><input name=t1 type=text size=20 value="NomeDocookie">
</td></tr>
<tr><td>Valor do Cookie:&nbsp;
</td><td><input name=t2 type=text size=20 value="Valor Do Cookie">
</td></tr>
<tr><td>Deve expirar em:&nbsp;
</td><td><input name=t3 type=text size=3 value="5"> Dias de hoje
</td></tr>
<tr><td></td><td><input name=b1 type=button value="Set Cookie"
onClick="SetCookie('__Teste__',rot13(this.form.t1.value,this.form.t3.value));
SetCookie(this.form.t1.value,this.form.t2.value,this.form.t3.value);">
</td></tr></table>
</form>
    
30.01.2014 / 12:55