Skip to content

Instantly share code, notes, and snippets.

@amgraham
Last active September 23, 2015 21:57
Show Gist options
  • Save amgraham/621683 to your computer and use it in GitHub Desktop.
Save amgraham/621683 to your computer and use it in GitHub Desktop.
Am easy way for an application to talk with itself.
class Memo {
// we're going to set the message to something, could be nothing (meaning we want the message cleared), or something to else.
function set($message = '') {
if (setcookie('memo', $message, time() + 60, '/')) {
return false;
} else {
return true;
}
}
// we're retrieving the message, also setting it blank.
function get() {
//$memo = file_get_contents($this->storage);
$memo = $_COOKIE["memo"];
Memo::delete();
if ($memo != '') {
return stripslashes($memo);
} else {
return false;
}
}
// different from set, as we delete it
function delete() {
setcookie('memo', '', time() - 60, '/');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment