This is the code I use, it is part of a class:
Code: Select all
/**
* @return void
* @param int
* @desc Will log in a user and make a cookie. Pass in for how long (in minutes)
* @date 12-19-03
*/
function login( $t ) {
if( $this->isLogedIn )
return;
$time = time() + ( $t * 60 );
setcookie('nlb3', $this->id . '::' . $this->dataї'password'], $time);
$this->isLogedIn = true;
}
/**
* @return VOID
* @desc Delete login cookies.
* @date 01-09-04
*/
function logout() {
setcookie('nlb3', "", time() - 3600); // set value to nothing, expire date in past
$this->isLogedIn = false;
unset( $_COOKIEї'nlb3'] );
}$user->login( $mins );
$user->logout();
I was thinking that the problem might be that I am running this all through http://localhost, but I started going by my ip address and the problem still exists. I am using print_r( $_COOKIE ) to confirm that the cookie exists after I call logout() and goto different pages.
The php manual on deleting cookies:
is the problem my browser? Im going crazy because im able to log out of forums and other scripts that use cookies, but not the one I createWhen deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser.