<?php

require 'browserhawk.php';

// This sample is provided under the terms of the BrowserHawk End User License
// Agreement.  Copyright (c) 2003-2006 cyScape, Inc.  All rights reserved.

// This example demonstrates how to use BrowserHawk to check for disabled
// cookies.  Note that with IE 5 and higher it is possible to have cookies
// disabled differently for "session" cookies (which expire immediately upon
// closing your browser) vs. "persistent" cookies (which expire at a date/time
// set at the time the cookie is created).  This example also shows you to
// detect the difference between session vs. persistent cookie settings.

// To avoid an ugly exception, we first check that the system executing this
// example has a Professional or Enterprise Edition license as required
// for this test.
// Note: This is NOT needed in your pages, only for this generic sample.
  if (strpos($BrowserHawk->getVersion(), "Pro") === false &&
      strpos($BrowserHawk->getVersion(), "Ent") === false) {
    echo "Professional or Enterprise License Required.  ";
    echo "You are using " . $BrowserHawk->getVersion() . ".  ";
    echo "See <a href='http://www.cyscape.com/order/'>http://www.cyscape.com/order/</a> for upgrade information.";
    return;
  }

// First we create an instance of the ExtendedOptions class so we can tell
// BrowserHawk which tests we want performed (in this case to test for
// disabled cookies).

// Now we tell BrowserHawk we want it to test for both disabled session and
// persistent cookies.
	
	$options->addProperties("SessionCookies, PersistentCookies");

// Tell BrowserHawk to execute the test now.  Note there are many useful
// optional settings that can be employed through the ExtendedOptions class
// passed in.  This is demonstrated in the popular.php sample - see that
// sample for more information.
  
  $einfo = bhextended($options);

// Now that we have the results let's display them.

?>

<html>
	<head>
		<title>BrowserHawk Sample - Detect disabled cookies (PHP)</title>
	</head>
	<body><font face="arial">
	<blockquote>
		The status of your cookies is as follows:
		<p>
		</p>
		Session cookies:
	<?php
		if ($einfo->getSessionCookies())
			echo "ENABLED";
		else
			echo "DISABLED";
	?>
		<p></p>
		Persistent cookies:
	<?php
		if ($einfo->getPersistentCookies())
			echo "ENABLED";
		else
			echo "DISABLED";
	?>

<HR>

<P>
<b><a href="cookies.php">Retry this test</a></b><P>
<b><a href="index.html">Return to list of other PHP samples</a></b><P>
<b><a href="http://www.cyscape.com/order/">BrowserHawk Pricing and Ordering</a></b><P>
<b><a href="http://www.cyscape.com/">cyScape home page</a></b><P>
</font>
</blockquote>
</body>
</html>
