Created
September 16, 2010 09:20
-
-
Save heatxsink/582170 to your computer and use it in GitHub Desktop.
cookies.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function validate_var($var) { | |
$return_value = false; | |
if (isset($var) && strlen(trim($var)) > 0) { | |
$return_value = true; | |
} | |
return $return_value; | |
} | |
$cookie_name = 'doctors_rule'; | |
$cookie_stage_domain = '.foo.com'; | |
$cookie_domain = '.nickgranado.com'; | |
$cookie_value = false; | |
$cookie_expires = time() - 3600; | |
$stage = $_GET['stage']; | |
if (validate_var($stage)) { | |
if ($stage == 1) { | |
$cookie_domain = $cookie_stage_domain; | |
} | |
} | |
$reset = $_GET['reset']; | |
if (validate_var($reset)) { | |
if ($reset == 0) { | |
$cookie_value = 1; | |
$cookie_expires = time() + 3600; | |
} | |
setcookie($cookie_name, $cookie_value, $cookie_expires, '/', $cookie_domain, false, true); | |
} | |
header('Location: /cookie_test.php'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment