You should have received a copy of the GNU General Public License along with cookie-consent-handler. If not, see <http://www.gnu.org/licenses/>. */ /** * Basic example for using cookie-consent-handler. * * @author Rhys Elsworth <*****@*****.**> * @version 2012-06-10 */ require_once '../inc/init_cookie_consent_handler.php'; require_once CCH_INC . '/accept_cookies.php'; require_once CCH_CLASSES . '/CookieConsentHandler.php'; require_once CCH_CLASSES . '/CookieConsentBar.php'; // Start a session if consent has been gained $consentHandler = new CookieConsentHandler(); $consentHandler->sessionStart(); ?> <!DOCTYPE html> <html> <head> <title> cookie-consent-handler: Example Usage </title> </head> <body> <h1>cookie-consent-handler: Example Usage</h1> <?php // Output consent bar $consentBar = new CookieConsentBar();
<?php /** * Handles action taken after consent has been given to use cookies. * * @author Rhys Elsworth <*****@*****.**> * @version 2012-05-17 */ require_once CCH_CLASSES . '/CookieUtils.php'; require_once CCH_CLASSES . '/CookieConfig.php'; require_once CCH_CLASSES . '/CookieConsentHandler.php'; $utils = new CookieUtils(); $config = new CookieConfig(); if (isset($_REQUEST[$config->get_accept_param]) && $_REQUEST[$config->get_accept_param]) { // Get an instance of the consent handler $c = new CookieConsentHandler(); // If consent has not yet been established, set the consent cookie now if (!$c->checkConsent()) { $c->setConsentCookie(); // Reload the current URL so that the browser sends the new cookie back to the server header("Location: " . $utils->getCurrentUrl()); exit; // Ensure no more output follows } }