Note that there are some explanatory texts on larger screens.

plurals
  1. POCookie weirdness in IE
    primarykey
    data
    text
    <p>I have some code that saves the user's ID as a cookie. It works fine in production, but moving the code to IIS7, upgrading the vendor app behind my code, and moving the app to an app in IIS7 instead of just running Default Web breaks this cookie function in IE. </p> <p>Unfortunately it's a Classic ASP app so I can't find a good way to post a working version. But here are the relevant pieces. </p> <p>Synopsis:</p> <ol> <li>when the user checks "remember me" and logs in, a temporary cookie is created </li> <li>when the user authenticates, the temp cookie is "promoted" to a permanent one and temp is expired</li> <li>when the user unchecks "remember me" both cookies are supposed to be expired</li> </ol> <p>What appears to be happening (just in IE?) is that there are 2 cookies, and unchecking the box only touches one of them.</p> <p>Here is the relevant code. Hope it helps :)</p> <p>On the login form:</p> <pre><code>var MHOLI = Get_Cookie("MHOLI"); //Check if cookie has a value if (MHOLI != null &amp;&amp; MHOLI != "" &amp;&amp; MHOLI != "null") { //Set login text $("#Login").val(MHOLI); //keep remember login checkbox checked $("#RemonlineID").attr('checked', true); $(document).ready(function() { setTimeout(function() { $("#Password").focus(); }, 200); }); } $(document).ready(function() { //test if cookies are enabled.. Set_Cookie('test', 'testvalue', '/', '', ''); //if cookies are disabled, disable the option to remember username if (!Get_Cookie('test')) { $('#RemonlineID').attr("disabled", true); } });​ </code></pre> <p>When the "remember me" checkbox is changed:</p> <pre><code>var loginForm = document.getElementById("loginForm"); if (!loginForm.RemonlineID.checked) { setCookie("MHOLI", null, null); setCookie("tmpMHOLI", null, null); }​ </code></pre> <p>When the login form is submitted, set a 1 day cookie if "remember me" checked:</p> <pre><code>if (loginForm.RemonlineID.checked) { setCookie("tmpMHOLI", loginForm.Login.value, 1); } else { setCookie("tmpMHOLI", null, null); }​ </code></pre> <p>The setCookie function. Yes, I see that <code>expstring</code> is there but never used :):</p> <pre><code>function setCookie(name, value, days) { var expireDate = new Date() //set "expstring" to either future or past date, to set or delete cookie, respectively var expstring = (typeof days != "undefined") ? expireDate.setDate(expireDate.getDate() + parseInt(days)) : expireDate.setDate(expireDate.getDate() - 5) document.cookie = name + "=" + value + "; expires=" + expireDate.toGMTString(); }​ </code></pre> <p>And then some VBScript once the user makes it into the application. I'm thinking that it is creating a second cookie instead of </p> <pre><code>if Request.Cookies("tmpMHOLI") &lt;&gt; "" then Response.Cookies("MHOLI") = Request.Cookies("tmpMHOLI") Response.Cookies("MHOLI").Expires = Date() + 365 Response.Cookies("tmpMHOLI") = "" end if​ </code></pre> <p>Is there something different about how IE7/8/9 handle cookies that this would not work? Is there something about IIS7.5 that is creating a cookie that the client script can't touch?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload