[RESOLVED] Setting cookies
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
I threw this code into the top of my "Logout.php" page, and it works in IE6 but not Firefox:
Code: Select all
$expiry = 1;
setcookie('user', '', $expiry);
header('Location: index.php');- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Clear your cache in FF. Also, use a full URL instead of a relative when using the header() function, as per the manual.
I tried clearing the cache, deleting the original cookie, and using the full http://www.mydomain.org/Directory/index.php and still no luck. It's still working in IE though.
Set it to the following, and moved it over to a subdomain and now it's working like a charm.
Code: Select all
if (isset($_COOKIE['user']))
{
$cookie_info = explode("-", $_COOKIE['user']);
$name = $cookie_info[0];
$pass = $cookie_info[1];
$cookie_data = $name.'-'.$pass;
$expiry = 1;
$directory = "";
$domain = "subdomain.mydomain.org";
setcookie ("user", $cookie_data, $expiry, $directory, $domain, "0");
header('Location: http://subdomain.mydomain.org/index.php');
}- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA