problem with cookies on MSIE
Posted: Thu Mar 18, 2010 10:25 am
I need to have users accept cookies for my application and I'm trying to determine if a user's browser is set to accept cookies. On the initial display of the login page, I clear any old cookie and then set a new cookie (see below - Part 1). After the user enters login and password info and submits the form, the program goes back to the login page php logic to check if the cookie was set. If not, an error message is displayed (see below - Part 2).
The problem is that on MSIE (after I change settings to NOT accept cookies), it blows by this Part 2 test without being caught. The cookie ends up being written (per my debug statements) even with settings to accept cookies being turned off, but I can't find any cookie. This works when I turn off cookies in Firefox. In addition, when I turn off cookies in MSIE and then try to sign into Yahoo, it blocks the sign in because cookies are not being accpeted, so I know that cookies are not being accepted.
Is there something I'm doing wrong in the code?
Where should I be able to find the cookie that is set?
Any other suggestions on how to resolve this?
Thanks!
The problem is that on MSIE (after I change settings to NOT accept cookies), it blows by this Part 2 test without being caught. The cookie ends up being written (per my debug statements) even with settings to accept cookies being turned off, but I can't find any cookie. This works when I turn off cookies in Firefox. In addition, when I turn off cookies in MSIE and then try to sign into Yahoo, it blocks the sign in because cookies are not being accpeted, so I know that cookies are not being accepted.
Is there something I'm doing wrong in the code?
Where should I be able to find the cookie that is set?
Any other suggestions on how to resolve this?
Thanks!
Code: Select all
# Part 1 - On the initial display of the login page,
# I clear any old cookie and then set a new cookie
if (isset($_COOKIE['Test']))
{
setcookie('Test', '', time()-42000, '/');
}
print "after cookie was cleared";
var_dump ($_COOKIE);
setcookie('Test', 1);
print "after cookie set";
var_dump ($_COOKIE);
exit();
-------
# Part 2 - After login info is entered, the program goes back
# to the login page php logic to check if the cookie was set.
# If not, an error message is displayed.
var_dump ($_COOKIE);
exit();
if( !isset($_COOKIE['Test']))
{
errorMessage...
}