Page 1 of 1
Determine client cookie support via initial headers?
Posted: Tue Feb 12, 2008 7:16 pm
by JAB Creations
When a browser makes it's initial request is there any way to determine through the headers sent by the browser if cookies are enabled?
For clarification a desirable time line...
1.) Client sends request with browser's headers.
2.) PHP needs to determine if client supports cookies.
3.) PHP either creates cookies and sends client an error message telling them to enable cookies.
If the client does not support cookies on the initial hit I need to make them aware before they make a second request. That is my goal.
Re: Determine client cookie support via initial headers?
Posted: Tue Feb 12, 2008 7:21 pm
by Benjamin
I'm fairly certain you'll have to attempt to set a cookie then immediately redirect to a page that will test that the cookie was set, then either redirect to the destination or an error page.
Re: Determine client cookie support via initial headers?
Posted: Tue Feb 12, 2008 7:30 pm
by JAB Creations
Using header in PHP is there a simple "reload/refresh" command I could use in conjunction with the header command to achieve this?
Re: Determine client cookie support via initial headers?
Posted: Tue Feb 12, 2008 7:32 pm
by Benjamin
Re: Determine client cookie support via initial headers?
Posted: Tue Feb 12, 2008 8:09 pm
by JAB Creations
How can we refresh the page using the following code
and add an HTTP query.
Code: Select all
if (!isset($_COOKIE['counter'])) {header('Refresh: 1;');}
I'd like to add an http query such as
?cookie=0 or
?cookie=1 depending on if cookies are detected for the purpose of statistical analysis.
Re: Determine client cookie support via initial headers?
Posted: Tue Feb 12, 2008 8:22 pm
by Benjamin
It would look more like:
Code: Select all
if (!isset($_COOKIE['counter']))
{
header('Location: http://domain.com/page.php?cookie=0');
} else {
header('Location: http://domain.com/page.php?cookie=1');
}
Re: Determine client cookie support via initial headers?
Posted: Tue Feb 12, 2008 8:29 pm
by JAB Creations
I know how to do that, I don't know the dynamic command for this-url, regardless of what it is. This PHP script needs to be dynamically used by multiple files where file names may constantly be changing.