(RESOLVED) Setting Cookies (Pt. 2)
Posted: Mon Aug 28, 2006 11:53 pm
This is sort of a continuation of this article.
I moved this site over to it's new, permanant, address, and I've run into an issue. I have a login on the left side of the page which is meant to give easy and quick access to the members only section of the site. When I login, it brings me to the main members page with all the "logged in" info being displayed properly, except the left login part still shows the username/password boxes, and I threw in an "echo "cookie not set";" in to it, and that shows up as well. The left login page is in the "members" subdomain, which I thought was the problem, beacuse I had it in the root directory at first. But that didn't make a difference.
However, when I go directly to the php page itself, it's showing me as logged in. This makes no sense to me what so ever.
I can't get this to work in FF 1.5 or IE 6
Index:
I moved this site over to it's new, permanant, address, and I've run into an issue. I have a login on the left side of the page which is meant to give easy and quick access to the members only section of the site. When I login, it brings me to the main members page with all the "logged in" info being displayed properly, except the left login part still shows the username/password boxes, and I threw in an "echo "cookie not set";" in to it, and that shows up as well. The left login page is in the "members" subdomain, which I thought was the problem, beacuse I had it in the root directory at first. But that didn't make a difference.
However, when I go directly to the php page itself, it's showing me as logged in. This makes no sense to me what so ever.
I can't get this to work in FF 1.5 or IE 6
Index:
Code: Select all
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$check = ( isset($_POST['set']) ) ? $_POST['set'] : ''; //The 'set' is if the user wants to be remembered
$cookie_data = $name;
$expiry = 0; //Expire when the browser is closed
$directory = "/";
$domain = "members.mydomain.com";
if ( $check )
{
$expiry = time() + 365*84000;
}
setcookie ("user", $cookie_data, $expiry, $directory, $domain, "0");
header('Location: http://members.mydomain.com/index.php');
}