Page 2 of 3
Posted: Sun Aug 06, 2006 7:45 pm
by LuiePL
OK I switched it to that now getting:
Cookie Set. Expires: 12/31/1969 8:00:00 PM
Time now: 08/06/2006 8:44:15 PM
And it's still saying that the cookie was not set in the body. Do I need to refresh the page in the code once it "sets" the cookie?
Posted: Sun Aug 06, 2006 7:47 pm
by Ambush Commander
Doink. $expiry = time() + 3600
Posted: Sun Aug 06, 2006 7:49 pm
by LuiePL
LOL, even I should have picked up on that.

Working now! Well, not the cookies, but the time is.
Posted: Sun Aug 06, 2006 7:50 pm
by RobertGonzalez
What do you expect the post var 'set' to contain?
Posted: Sun Aug 06, 2006 7:54 pm
by LuiePL
Everah wrote:What do you expect the post var 'set' to contain?
It's a boolean check box for if the user wants to stay logged in.
Posted: Sun Aug 06, 2006 7:58 pm
by RobertGonzalez
Bear in mind that checkboxes pass as either 'On' or empty. If it is empty, checking the value it in a compariosn or assigning it will throw an undefined index notice.
Posted: Sun Aug 06, 2006 8:20 pm
by LuiePL
I'm not too sure if it is setting it correctly though. My administration page is setup to read the cookie with the following code, and it's keeps telling me that I'm not authorized. So that leads me to believe it's not setting properly.
Code: Select all
if (isset($_COOKIE['user']))
{
$cookie_info = explode("-", $_COOKIE['user']);
$name = $cookie_info[0];
$pass = $cookie_info[1];
$dbh = mysql_connect ("localhost", "name", "password") or die ('Database Connection Error: ' . mysql_error());
mysql_select_db ("database");
$query = "SELECT * FROM Login WHERE name='$name' AND password='$pass'";
$sql = mysql_query($query); //or die(mysql_error());
$count = mysql_num_rows($sql);
$queryadmin = "SELECT * FROM Login WHERE name='$name' AND admin='-1'";
$sqladmin = mysql_query($queryadmin);
$countadmin = mysql_num_rows($sqladmin);
if ($countadmin == 1)
{
echo "<center><span class='RED'><h1>Administration Panel</h1></span>";
echo "<BR><a href='../MembersOnly.php'>Members Only</a>";
echo "<BR><a href='../Logout.php'>Logout</a></center>";
}
}
else
{
echo "<CENTER><SPAN CLASS='RED'>You are not an administrator</SPAN>";
echo "<BR><A HREF='../index.php'>Home</a></CENTER>";
}
Posted: Sun Aug 06, 2006 8:22 pm
by Ambush Commander
Can you repost the entire index.php please?
Posted: Sun Aug 06, 2006 8:25 pm
by LuiePL
Either of you know why this would work in IE6 but not Firefox 1.5? I just did a quick check and got it working in IE without a problem. If that's the case, I'd rather work on a firefox problem than a entire page problem.
Posted: Sun Aug 06, 2006 8:27 pm
by Ambush Commander
Well, that explains everything!
Yeah, Firefox is rejecting cookies from the website.
Tools > Options > Privacy > Cookies
Noodle with those options. Make sure your development domain isn't blacklisted.
Posted: Sun Aug 06, 2006 8:38 pm
by LuiePL
I tried tinkinering with that, including explicity
allowing the domain with and without the "
www." Still won't take it though...
Posted: Sun Aug 06, 2006 8:40 pm
by feyd
If you have the web developer extension, view the response headers from this page. It may be telling.
Posted: Sun Aug 06, 2006 8:41 pm
by Ambush Commander
Let's check the obvious: you do have "Allow sites to set cookies" checked right? You can try removing all sites and see if that helps. Try clearing all cookies too.
Posted: Sun Aug 06, 2006 8:51 pm
by LuiePL
OK, cleared the cookies and got it work. I also had to change one part in my body code. It was trying to act like it was posted to if the cookie was set, but I switched the following code:
Code: Select all
$name = $_POST['name'];
$pass = md5($_POST['pass']);
To:
Code: Select all
$cookie_info = explode("-", $_COOKIE['user']);
$name = $cookie_info[0];
$pass = $cookie_info[1];
So it authenticates you properly if you go to the main page and the cookie is still set. But besides that, it looks likes it's functioning corrctly at this point, I got to tinker with the logout page so it clears it properly, but step 1 is complete. Thanks.
Posted: Sun Aug 06, 2006 9:01 pm
by LuiePL
I don't know what I'm doing wrong, but I thought clearing cookies was easier. This is my code at the top:
Code: Select all
if (isset($_COOKIE['user']))
{
setcookie ("user", "", time() - 3600);
}