[thelist] PHP site - Cannot send cookies???

Flavia Silveira-Tarzwell (FayeC) fayec at canada.com
Thu Jul 26 17:06:01 CDT 2001


Ok,

I got several emails with this same answer but this doesn't explain how
the site works perfectly on one server and not on another...
I checked the pages and there is absolutely nothing before the <? .
It is alwyas on line 1 on all pages.
WHat makes things even more puzzling is the fact that the code was
passed to us by our teache who has a whole site working based on this
code on a real server and the site works without problems.....
The code doesn't even have a setcookie function.....
In case any of you is interested in breaking the code please let me know
and I will mail the code to you privately....
Thank you in advance.

FayeC

<tip>
When having problems showing an image in your php code, open the page on
Netscape, right-click on the image and select View image.
That will help you determine if the problem is the image or just a bad
link to it.
If the link to the image shows correctly and the imagge still doesn't
show, check to see if the image is in the right folder. 
</tip>


Seb wrote:
> 
> Yesterday, FayeC asked:
> 
> > I am working on a site for a school assignment. The teacher told us to
> > host the site in a "real" server and keep a copy of it at the school's
> > server.The site was initially built and debugged at the school's server
> > and it works there. After transfering the files to f2s and changing the
> > db connection the site doesn't work as before and I get many errors ...
> > The site in question is:
> > www.fayec.f2s.com  the school's counterpart is at:
> > http://delta.humberc.on.ca/summer2001php/fayec/index.php
> >
> > As We just started PHP a week ago my knowledge of the language is
> > minimal and I can't figure out why it is telling me that the cookies
> > cannot be sent...
> 
> Hi Faye,
> 
> My guess is that your code has already output something before you call the
> setcookie() function. setcookie() is a variant of the header() function,
> which sends an HTTP header to the browser. Because of the way in which the
> HTTP response works, you must send all headers, including cookies, before
> any content is sent to the browser.
> 
> Common things to check for include ANY whitespace outside of the <? ?>
> delimiter tags. If there is ANYTHING at all outside of these tags before
> your call to setcookie(), then you will not be able to send a cookie, or any
> other header. FYI, there should never be any whitespace outside the php
> delimiter tags unless you are intentionally sending it to the browser, as
> whitespace outside tags is not generally considered a valid method of
> formatting php code.
> 
> To check this, immediately before calling setcookie(), use the
> headers_sent() function. This will return TRUE if the HTTP headers have
> already been sent, meaning you cannot send your cookie at this point in the
> code. It will return FALSE if the headers hae not been sent, and you will be
> able to call setcookie() successfully.
> 
> You might need to restructure your code in order to ensure that setcookie()
> is called before any content is sent to the browser. This should be quite
> straightforward because your HTML output should not affect the value of your
> cookie. If you are still having problems, you might want to investigate the
> use of the output buffer. For more information on this, see:
> http://www.php.net/manual/en/ref.outcontrol.php and
> http://zend.com/zend/art/buffering.php
> 
> Hope this helps, feel free to mail me if you have any problems.
> 
> Cheers,
> 
> Seb
> http://www.sebpotter.org
> 
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !

-- 
Flavia Tarzwell (FayeC)
Web Designer/Developer
http://www.3xtend.com
Extend your Web presence.




More information about the thelist mailing list