First check that you are not sending any content before trying to set the cookie :

It effectively is sending a header, and headers must be sent before any other content - even a white space before your PHP script which sets your cookie will send headers so then your cookie will not be set.

You can check if headers have been sent with the convenient headers_sent() PHP function, which returns true if headers have already been sent.

That's the most likely diagnosis IME, if everything else checks out.

Cheers - Neil.

At 13:26 07/02/2004 +0000, you wrote:
From: "Donovan Hutchinson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Sat, 7 Feb 2004 13:26:25 -0000
MIME-Version: 1.0
Content-Type: multipart/alternative;
        boundary="----=_NextPart_000_0039_01C3ED7D.FC683AD0"
Message-ID: <[EMAIL PROTECTED]>
Subject: Cookie problem

Hi,

I'm trying to use PHP to set a cookie to recognize people returning within a month. However no matter how i use the code, no cookie is being set. I've been in touch with my host, who assures me that cookies function in the 'normal' way on their servers, so its probably something wrong with my code. I'm using this:

$time = mktime()+(60*60*24*30);
setcookie('lifevision', $dist_id, $time, '/', 'www.dono.co.uk','0');

i've also tried without the "www" and without the "www." in the domain. To test if the cookie is being set, the url www.dono.co.uk/testing/ should set a cookie. It also starts a session for people who can't accept cookies. (i've also put a print_r at the end of the page to print the cookie contents, if any) However the cookie just isnt appearing. Any suggestions appreciated,

Don


========================================================
CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to