smudgemouse
asked on
PHP; Set Cookies Not Working
Having trouble setting cookies in different browsers.
The following snippet sets cookies in Firefox for the PC and for the Mac.
It does not set them in Safari or in IE7.
Safari does, however, respond to session_start() with a blank PHPSESSID.
Code is:
<?php session_start();
require_once('../Connectio ns/conn_33 3mysql.php '); ?>
<?php
if (! isset($_COOKIE["selectfc"] ))
{$rand = rand(10000,99999);
$expyr = 60 * 60 * 24 * 365 + time();
setcookie("selectfc", $rand, $expyr, "/", " ",0 );
}
?>
Could somebody help with our errors please?
The following snippet sets cookies in Firefox for the PC and for the Mac.
It does not set them in Safari or in IE7.
Safari does, however, respond to session_start() with a blank PHPSESSID.
Code is:
<?php session_start();
require_once('../Connectio
<?php
if (! isset($_COOKIE["selectfc"]
{$rand = rand(10000,99999);
$expyr = 60 * 60 * 24 * 365 + time();
setcookie("selectfc", $rand, $expyr, "/", " ",0 );
}
?>
Could somebody help with our errors please?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hey, smudgemouse - thanks for the points. Good luck with your project! ~Ray
and what your problem is...
bool setcookie ( string $name [, string $value [, int $expire [, string $path [, string $domain [, bool $secure [, bool $httponly ]]]]]] )
http://tr2.php.net/setcookie
you give the path "/" on your server, but probably you don't have permissions to write there. try "/tmp/". also if you don't write correct domain, most browsers won't accept your cookie as a security matter. so do the two above like that:
setcookie("selectfc", $rand, $expyr, "/tmp/", "mydomain.com",0 );