Hi all!

Since I am new to PHP, I need the help of someone who is very familiar with
the way PHP handles the setting of cookies and page redirection - in other
words, an expert!

Here is an outline of the problem:
1) client browser hits myPage.php
2) myPage.php does a few checks & recognises that this is a first visit
3) myPage.php sets a cookie using setCookie()
4) myPage.php redirects to checkBrow.php which uses JavaScript to do some
basic browser detection
5) checkBrow.php does checks and looks for cookie written by myPage.php
6) checkBrow.php fails to find the cookie because header( "Location:
http://someaddress"; ) in step (4) has trashed the header containing the
cookie information!! Note that ob_start() has to be used to prevent any data
being sent to the client before the header has been set.. i.e. the page is
being cached server-side.

myPage.php was originally written in ASP and worked fine. ASP seems to write
the cookie back to the client browser first, and *then* performs a redirect.
PHP on the otherhand seems to overwrite any existing headers when using
header( "Location: http://someaddress"; ) because they are cached. While this
behaviour seems obvious it presents some rather annoying problems. I've
kludged a fix by setting the cookie and then writing a page that uses a
<META> refresh to redirect...

Is there a more elegant way of doing this?? Please please tell me there is
because I hate having to do such a crappy workaround. If you need more info
on what the html headers look like - before and after - mail me and I'll be
happy to provide you with them...

Cord Schneider

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

Reply via email to