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.
Determine client cookie support via initial headers?
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Determine client cookie support via initial headers?
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.
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Determine client cookie support via initial headers?
Using header in PHP is there a simple "reload/refresh" command I could use in conjunction with the header command to achieve this?
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Determine client cookie support via initial headers?
How can we refresh the page using the following code and add an HTTP query.
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.
Code: Select all
if (!isset($_COOKIE['counter'])) {header('Refresh: 1;');}Re: Determine client cookie support via initial headers?
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');
}
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Determine client cookie support via initial headers?
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.