Link to home
Start Free TrialLog in
Avatar of DistillingExperts
DistillingExperts

asked on

Cookie not being saved in IE 8

This function is not saving the data in the Internet Temporary Files folder. Any reason why (Windows 7, IE 8)?
function setCookie(name, value, expires, path, domain, secure)
{
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

This looks more like Javascript than PHP, so I think you might need to repost it in the javascript forum..... still from the code above my first guess would be that expires.toGMTString() is outputting either the current time or a historic time. In either of these cases the cookie expires as soon as you write it. Check expires.toGMTString() and make sure its expiry is in the future - even if only an hour.

Next, have you checked if these expires in other browsers because you only mention IE8. If it is OK in other browsers then check the following items which are known to cause cookie problems for IE

1. What is the server's clock showing for time. If the server's clock is different from yours IE will expire the cookie

2. Does the website contain an underscore in the domain name? If so then IE tends to drops sessions and cookies

Try that lot out and post back with the results.
Make sure that cookies is not disabled on IE.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial