Jump to content

setcookie working in Firefox but not Internet Explorer..?


rhyspaterson

Recommended Posts

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

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.

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..

  • 2 years later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.