Got an odd problem here. I've written some simple code to check if the user's browser is set to accept cookies. This process works flawlessly in Mozilla and Mozilla Firefox but not on IE.
On the first page I set the following: (I'm using session_start(); on both pages)
$_SESSION['test_cookie'] = "yes";
Then the user clicks a button which sends them to a page containing this code:
<?php
session_start();
extract($_SESSION);
//print $_SESSION['test_cookie'];
if (@$_SESSION['test_cookie'] != 'yes')
{
echo "<b><u><center>Either you chose not to accept the cookie or your browser is set to reject cookies</b></u><p>
You can fix this by following the steps below.<p>
First, select the browser you are using.<p>
<a href='ie.htm'>Internet Explorer</a><p>
<a href='mozilla.htm'>Mozilla</a><p>";
}
else
{
echo "Cookies are enabled!";
}
Note that I have commented out print $_SESSION['test_cookie']?
Well if I comment out everything below the print command and uncomment the print line so that I can see exactly what is in the $_SESSION['test_cookie'] variable, IE tells me it contains the value "yes" (set from the first page even though cookies had been disabled), while Moz tells me the following: Notice: Undefined index: test_cookie in C:\Web\cookie_test.php on line 4.
Line 4 is the print command.
I have no clue why this is happening.
Any ideas?