Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7569137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:05:53+00:00 2026-05-30T15:05:53+00:00

I have some code that saves the user’s ID as a cookie. It works

  • 0

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.

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.

Synopsis:

  1. when the user checks “remember me” and logs in, a temporary cookie
    is created
  2. when the user authenticates, the temp cookie is “promoted” to a
    permanent one and temp is expired
  3. when the user unchecks “remember me” both cookies are supposed to be
    expired

What appears to be happening (just in IE?) is that there are 2 cookies, and unchecking the box only touches one of them.

Here is the relevant code. Hope it helps 🙂

On the login form:

var MHOLI = Get_Cookie("MHOLI");
//Check if cookie has a value
if (MHOLI != null && MHOLI != "" && 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);
    }
});​

When the “remember me” checkbox is changed:

var loginForm = document.getElementById("loginForm");
if (!loginForm.RemonlineID.checked) {
    setCookie("MHOLI", null, null);
    setCookie("tmpMHOLI", null, null);
}​

When the login form is submitted, set a 1 day cookie if “remember me” checked:

if (loginForm.RemonlineID.checked) {
    setCookie("tmpMHOLI", loginForm.Login.value, 1);
}
else {
    setCookie("tmpMHOLI", null, null);
}​

The setCookie function. Yes, I see that expstring is there but never used :):

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();
}​

And then some VBScript once the user makes it into the application. I’m thinking that it is creating a second cookie instead of

if Request.Cookies("tmpMHOLI") <> "" then
  Response.Cookies("MHOLI") = Request.Cookies("tmpMHOLI")
  Response.Cookies("MHOLI").Expires = Date() + 365
  Response.Cookies("tmpMHOLI") = ""
end if​

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:05:54+00:00Added an answer on May 30, 2026 at 3:05 pm

    I ended up refactoring my setCookie() function. I was not properly expiring the cookies because the date calculations were funky. The quirksmode createCookie() function worked correctly.

    Also, I set the path on the cookie when I set it server-side. Somehow the paths were different for cookies set by the prelogin and post login pages. So then the client script couldnt override the server side cookie and vice versa. Explicitly setting the path fixed that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code in my project that saves an object to the database,
I have some code that gives a user id to a utility that then
I have some VBA code that saves the spreadsheet under a given filename. Whenever
I have a web app that gathers some data from the user and saves
I have some code that uses the shared gateway pattern to implement an inversion
I have some code that raises PropertyChanged events and I would like to be
I have some code that looks like: template<unsigned int A, unsigned int B> int
I have some code that generates image of a pie chart. It's a general
I have some code that effectively does this : File file = new File(C:\\Program
I have some code that I am putting in the code-behind of a master

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.