Page 1 of 1

Disable client Cookie from Serverside

Posted: Tue Apr 19, 2005 8:06 pm
by windforceus
Hi everyone

I am working on a email system which will record the date and customers ID to MySQL when customers open the HTML email i sent to. The idea is to add a image link in the HTML email and the page will load image from my php page. In my php page, i will create images and record information to database. Every thing works but there is one problem. The outlook will load all the images in one time; therefore, the result wont' be accurate. For example, customers could open the HTML email for 10 times from Outlook but i only record 1 time. I removed the cookie in my browser and every thing works perfect. However, can i disable/delete the cookie in client side? I post some codes here to give you guys an idea.

Here is part of my email send function:

Code: Select all

session_start();
require_once("db_cns.php");
require_once("Mime/Mime/Mime.php");
require_once("Mail/Mail/Mail.php");

//get all the information for HTML email
$message=$HTTP_SESSION_VARS['message']; 
$subject=$HTTP_SESSION_VARS['subject']; 
$content=$HTTP_SESSION_VARS['content']; 
$emaillist=$HTTP_SESSION_VARS['emaillist']; 
$user=$HTTP_SESSION_VARS['user']; 
$idlist = $HTTP_SESSION_VARS['idlist']; 
$emailsize = $HTTP_SESSION_VARS['emailsize']; 

$hdrs = array(
              'From'    => $user,
              'Subject' => $subject
              );
$crlf = "\r\n";

$mime = new Mail_mime($crlf);

$j=0;
// send HTML email 
while($j<$emailsize)
{

	$link = "<img src=\"http://10.10.0.31/email/email/test.php?cid=".$idlist[$j]."\" >";
	$htmlcontent = $content.$link;
	$mime->setHTMLBody($htmlcontent);
	$mime->setTXTBody($message);
	$body = $mime->get();
	$hdrs = $mime->headers($hdrs);
	$mail =& Mail::factory('mail');
	$mail->send("client@hotmail.com", $hdrs, $body);

	$j++;
}

?>
here is my php page which record the information to database:

Code: Select all

<?php
include "db_cns.php";

//create image
header('Content-type: image/jpeg');
$images = imagecreatefromjpeg("image/space.jpg");
imagejpeg($images);

//store information to database
	$clientid = $cid; 
	$time = date("F j, Y, g:i a"); echo "date:".$time;
	$query = "INSERT INTO `record` VALUES ('','$time','$cid')";
	$result=mysql_query($query);
	if (!$result)
	{
		echo 'ERROR!';
		exit;
	}
Jcart | Please use

Code: Select all

tags when posting code.   [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Tue Apr 19, 2005 8:12 pm
by Smackie
for starts please use the PHP coder for the Forum and second of all check http://www.php.net for some help for the cookie problem


Smackie

Posted: Tue Apr 19, 2005 9:11 pm
by John Cartwright
You cannot "disable" their cookie functions, but you can delete your own cookies you have set (in other words expire).

Code: Select all

setcookie('cookie',time()-3600);
This will expire $_COOKIE['cookie']

Posted: Tue Apr 19, 2005 11:55 pm
by feyd
be aware that a lot of email clients are turning off or have turned off immediate level support for images. Unless they are inline to the email, most clients will only show the images if the user tells it to.

Regard the cookie reply

Posted: Wed Apr 20, 2005 5:17 pm
by windforceus
I know I can disable my cookie. My problem is when clients use outlook to receive my html email. I need to do something to make outlook load my image every time clients open it.Someone plz give me some idea. I am stuck.