Jump to content

[SOLVED] PHP cookies - cannot delete!


bluefusionxl

Recommended Posts

Okay so my PHP cookies are created fine.  But then on a different page where I try to delete them, it's a different story.  It seems it creates a new cookie and deletes the new instance, from what I've experimented by setting the time forward instead of in the past.  The original cookies are untouched.  Firefox and IE has trouble with this.  Opera does not.

 

Cookie Creation

<?php
if ($_SESSION['level']=="") {
if (isset($_POST['rm_user'])) {
$signin = new signin();
$status = $signin->execute($_POST['rm_user'],$_POST['rm_pass']);
if($status==1) {
		//Setting user sessions
		mysql_connect($db_host,$db_user,$db_pass) or die($error_db_connect);
		mysql_select_db($db_name) or die($error_db_select);
		$signin_query = mysql_query("SELECT * FROM users WHERE username='{$_POST['rm_user']}' LIMIT 1") or die($error_db_select);          
		$_SESSION['level'] = mysql_result($signin_query,0,"level");
		$_SESSION['username'] = mysql_result($signin_query,0,"username");
		mysql_close();
		//Setting remember me cookie
		if ($_POST['rm_remember']=="Remember") {
		$rm_pass = md5($_POST['rm_pass']);
		setcookie("remember1",$_POST['rm_user'],time()+60*60*24*14,"/",$domain,0);
		setcookie("remember2",$rm_pass,time()+60*60*24*14,"/",$domain,0);
		}	
	echo("
		<script type='text/javascript' language='javascript'>
		<!--
		document.location='{$http_url}';
		//-->
		</script>
		");
}
else {
	define("tpl_page",$page_user_login);
	$init_page = new template();
	$init_page->display("header");
	$init_page->display("user_login_error");
	//$init_page->ad("leader");
	$init_page->display("footer");
}
}
else {
define("tpl_page",$page_user_login);
$init_page = new template();
$init_page->display("header");
$init_page->display("user_login");
//$init_page->ad("leader");
$init_page->display("footer");
echo($_SESSION['level']);
}
}
else {
echo("<script type='text/javascript' language='javascript'>
	<!--
	var answer = confirm('{$error_signedin}');
		if (answer){
		window.location = '{$http_url}/sign-out';
		}
		else{
		history.back();
		}
	//-->
	</script>");
}                      
?>

 

Cookie Deletion

<?php
  /*-------------------------------------------------------------
  #		            -user.php-				#
  #	   Created by BlueFusionX Networks for Scoped.tv	#
  #		Created on Mon July 09 2007 12:18 AM		#
  #		Revised on Mon July 09 2007 12:18 AM       	#								
  --------------------------------------------------------------*/
//Here we start user sessions
session_start();
//Here we are auto-loading the classes for specific functions
function __autoload($al_class) {
require_once ("inc/classes/{$al_class}.php");
}

//Here we load global files needed for the script
require("inc/global.php");

//Here we produce the login page
if ($act=="signin") {
require("signin.php");
}
elseif ($act=="signout") {
unset($_SESSION);
session_destroy();
setcookie("remember1","",time()-3600,"/",$domain,0);
setcookie("remember2","",time()-3600,"/",$domain,0);
echo("<script type='text/javascript' language='javascript'>
alert('{$message_signedout}');
document.location='{$http_url}/sign-in';
//-->
</script>");
}
?>

Link to comment
Share on other sites

Wouldn't it be:

 

setcookie("remember1","", time()-60*60*24*14,"/",$domain,0);
setcookie("remember2","",time()-60*60*24*14,"/",$domain,0);

 

It looks like your doing (60*60*24*14 - 3600) which won't expire the cookie. That's not long enough right?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.