I'm making a login system with PHP right now, but my cookies are really weird. Here are my parts of code with cookies in them:
Check_Login.php:
this is when you try to login, $count is if your username and password are valid or not.
if($count==1){
setcookie("user", $loginname, time()+3600);
header("location:email.php");
}
else {
echo "Wrong Username or Password";
header("location:default.php");
}
Logout.php
when you logout.
<?
setcookie("user", "", mktime(12,0,0,1, 1, 1990));
?>
test.php
this is just to test out my cookies.
<?php
if (isset($_COOKIE["user"]))
echo "Welcome " . $_COOKIE["user"] . "!<br />";
else
echo "Welcome guest!<br />";
echo isset($_COOKIE["user"]);
?>
So the problem is that when I login and logout, then i go to test.php, it shows that the cookies is still there. also, if i login as "bob", logout, login as "joe", and i go to test.php, it shows im logged in as "joe". But then if i do some random stuff, it shows im logged in as "bob" again.
Help please?
Check_Login.php:
this is when you try to login, $count is if your username and password are valid or not.
if($count==1){
setcookie("user", $loginname, time()+3600);
header("location:email.php");
}
else {
echo "Wrong Username or Password";
header("location:default.php");
}
Logout.php
when you logout.
<?
setcookie("user", "", mktime(12,0,0,1, 1, 1990));
?>
test.php
this is just to test out my cookies.
<?php
if (isset($_COOKIE["user"]))
echo "Welcome " . $_COOKIE["user"] . "!<br />";
else
echo "Welcome guest!<br />";
echo isset($_COOKIE["user"]);
?>
So the problem is that when I login and logout, then i go to test.php, it shows that the cookies is still there. also, if i login as "bob", logout, login as "joe", and i go to test.php, it shows im logged in as "joe". But then if i do some random stuff, it shows im logged in as "bob" again.
Help please?