rhyspaterson Posted August 6, 2007 Share Posted August 6, 2007 Hey guys, I want to run a check on my login page to ensure that the user has cookies enabled. The cookie seems to be getting set in Firefox 1.5 and 2, but not in Internet Explorer (in both 6 and 7). I have double checked security settings to ensure cookies are allowed and so on. index.php (the first page) <?php session_start(); // check if cookie has been set or not if ($_GET['set'] != 'yes') { // set cookie setcookie('test', 'test', time() + 60); // reload page header("Location: index.php?set=yes"); } else { // check if cookie exists if (!empty($_COOKIE['test'])) { // cookies are enabled, open login page header("Location: http://10.20.20.118/login.php"); $_SESSION['cookie'] = 'true'; } else { //cookies are not enabled include('test/included_files/header_plain.inc'); include('test/included_files/nocookie.inc'); include('test/included_files/footer.inc'); } } ?> Any suggestions...? Cheers as always. /Rhys Link to comment https://forums.phpfreaks.com/topic/63506-setcookie-working-in-firefox-but-not-internet-explorer/ Share on other sites More sharing options...
tibberous Posted August 6, 2007 Share Posted August 6, 2007 I commented out the includes and ran the page like this: <?php session_start(); // check if cookie has been set or not if ($_GET['set'] != 'yes') { // set cookie setcookie('test', 'test', time() + 60); // reload page header("Location: index.php?set=yes"); } else { // check if cookie exists if (!empty($_COOKIE['test'])) { // cookies are enabled, open login page //header("Location: http://10.20.20.118/login.php"); $_SESSION['cookie'] = 'true'; die("cookies are enabled, open login page"); } else { //cookies are not enabled //include('test/included_files/header_plain.inc'); //include('test/included_files/nocookie.inc'); //include('test/included_files/footer.inc'); die("cookies are not enabled"); } } ?> In IE 6 and FF 2 I got the message that cookies were enabled. Maybe something is off with your version of IE? You could try clearing the old cookies, reopening everything, ect. Link to comment https://forums.phpfreaks.com/topic/63506-setcookie-working-in-firefox-but-not-internet-explorer/#findComment-316537 Share on other sites More sharing options...
rhyspaterson Posted August 9, 2007 Author Share Posted August 9, 2007 Thanks for the reply! I tried the exact code but still can not seem to get it to work in IE. Have tried in both 6 and 7 on multiple computers, with security settings on off, even entering my domain into the 'sites' section as allow. Man im confused.. Link to comment https://forums.phpfreaks.com/topic/63506-setcookie-working-in-firefox-but-not-internet-explorer/#findComment-319071 Share on other sites More sharing options...
adiva Posted March 20, 2010 Share Posted March 20, 2010 Check your address. If you use "_" (underscore) in your domain (like this www._test.com) IE6 does not work. Try using "www.test.com"... session_start() or cookie's php functions will magically work properly! I LOVE MICROSOFT! Link to comment https://forums.phpfreaks.com/topic/63506-setcookie-working-in-firefox-but-not-internet-explorer/#findComment-1029103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.