Why Cookies?
I'm using them for controlled access to certain pages. Here's how I create it:
This works wonderfully.
The Problem?
LOGGING OUT.
Here's what I have right now and it doesn't seem to be working so well.
do you guys have any clues why this is not deleting my cookie that is holding all of the login information?
here's the errors i'm getting by the way: (all 4 appear)
Warning: Cannot modify header information - headers already sent by ...
Warning: Cannot modify header information - headers already sent by ...
Warning: session_destroy(): Trying to destroy uninitialized session in ...
Warning: Cannot modify header information - headers already sent by ...
Thanks again and cheerio
-------
I'm using them for controlled access to certain pages. Here's how I create it:
Code:
if($_POST['Submit']){
//assign a variable to the username the user input
$username = $_POST['user'];
//assign a password to the username the user input
$password = $_POST['pass'];
if ($username=="coolThing" && $password=="coolPass){
// If username and password is right , store the session in a cookie
setcookie ('logedin', '1',time()+30000); // Set the length of the cookie to 30000
//Create the Session id's (as many as you want, can also do the same with cookied)
$_SESSION['logedin'] = "1";
$_COOKIE['logedin'] = "1";
}
}
?>
The Problem?
LOGGING OUT.
Here's what I have right now and it doesn't seem to be working so well.
Code:
<?
// If the form was submited Log Off The User
if($_POST['logoff']){
// Delete the cookie
setcookie ('logedin','');
// Set its time to minus 300 (more secure)
setcookie ('logedin' , '',time()-300);
// End All Session ID'S
$_SESSION = array();
// KILL ALL SESSIONS
session_destroy();
//Rdirect User our
//Redirect user out
header("Location: login.php");
exit();
}
?>
here's the errors i'm getting by the way: (all 4 appear)
Warning: Cannot modify header information - headers already sent by ...
Warning: Cannot modify header information - headers already sent by ...
Warning: session_destroy(): Trying to destroy uninitialized session in ...
Warning: Cannot modify header information - headers already sent by ...
Thanks again and cheerio
-------