[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Cookie not being saved in IE 8

Posted on 2011-04-21
Medium Priority
Last Modified: 2012-05-11
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;
Question by:DistillingExperts
LVL 34

Expert Comment

by:Beverley Portlock
ID: 35440248
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.
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35442051
Make sure that cookies is not disabled on IE.
LVL 111

Accepted Solution

Ray Paseur earned 2000 total points
ID: 35448101
I am fairly sure that is not PHP code, because PHP already has a function named setcookie() so the definition of a new function named setcookie() will cause a fatal error.  I think what you have there is a piece of JavaScript.   You can use the "Request Attention" link to ask a moderator to add this question to the JavaScript Zone.

But before you do that, consider whether setting cookies in Javascript is a good idea.  JavaScript cookies may represent a security threat.  Make a Google search for "javascript cookie security" and learn about cross-site scripting.  If you decide you want to set your cookies in the PHP script we can show you how to do that, and how to hide the cookies from JavaScript.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month18 days, 15 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question