Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting cookie

Status
Not open for further replies.

jl8789

MIS
Joined
May 22, 2003
Messages
293
Location
US
I have some javascript that is in my application that keeps deleting a cookie that I am setting elsewhere in my application. I do NOT want to delete the said cookie, called 'UserRegion'. Here is the javascript:
function removeCookies(){
Runtime Error in QADS, check if document exists
if (document.orderdetail){
if(document.orderdetail.closer.value == 0)
{
expires = new Date
expires.setMonth(expires.getMonth() - 1)

if (document.cookie != ""){
thisCookie = document.cookie.split("; ")
for (x=0; x < thisCookie.length; x++){
document.cookie = thisCookie[x].split("=")[0] + "=;expires=" + expires.toGMTString()
}
}
}
}
}

How do I add code to this so that it overlooks the cookie named, 'UserRegion', and does not delete it or basically change it to expire.

THANKS!!!!!!
 
I think this will do what you want...
Code:
function removeCookies(){
Runtime Error in QADS, check if document exists
    if (document.orderdetail){
        if(document.orderdetail.closer.value == 0)
        {
            expires = new Date
            expires.setMonth(expires.getMonth() - 1)
            
              if (document.cookie != ""){
                  thisCookie = document.cookie.split("; ")
                  for (x=0; x < thisCookie.length; x++){
                    [COLOR=red]if (thisCookie[x].split("=")[0] != 'UserRegion')[/color]
                      document.cookie = thisCookie[x].split("=")[0] + "=;expires=" + expires.toGMTString()
                  }
              }
        }
    }
}

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Cool. I just had to make sure the case was what it was in the cookie, 'USERREGION', and that worked.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top