note 33655 added to reserved.variables
| From: | ?phpecho\"JedHunsaker\"? at rack1 dot php dot net | Date: | Thu, 03 Jul 2003 06:00:45 +0000 |
| Subject: | note 33655 added to reserved.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51398@lists.php.net to get a copy of this message | ||
// This script saves all $_POST data into cookies named as $_POST's key for each. Can easily be
changed to $_GET or
// $_REQUEST or whatever you want. IIS on Windows XP Pro only allows 20 cookies though, so be
careful. I had to play
// some tricky crap with arrays and the explode() and implode() functions to get that working!
if (isset($_POST['reset'])) { // Name an HTML form submit button "reset" to
delete all cookies within the current domain
foreach ($_COOKIE as $key => $value)
setcookie($key, $value, time()-3600);
}
else { // Store all post data to cookies
foreach ($_POST as $key => $value) {
if (!empty($value)) {
$_COOKIE['$key'] = addslashes($value);
setcookie($key, addslashes($value), time()+60*60*24*7);
}
}
}
// You can add much more functionality to this script than I show but this gets the foundation. If
you want to store
// only particular variables, create an array with those variable names and foreach through their
values, executing
// an eval statement to store each cookie respectively. You can get quite creative. I have code for
it.
// Email me with any questions at str_replace("%nospam%", "lavadrop",
"jed@%nospam%.com");
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33655
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33655&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33655&report=yes