note 98139 added to function.serialize
| From: | regality at gmail dot com | Date: | Thu, 27 May 2010 22:30:47 +0000 |
| Subject: | note 98139 added to function.serialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169673@lists.php.net to get a copy of this message | ||
serialize can be a handy tool for protecting against page expirations if you are using POST's.
In my code I call the following function whenever I detect that the page has expired.
<?php
function savePost() {
// Save this in the login form
if (isset($_POST['savePost'])) {
echo "<input type='hidden' name='savePost'
value=\"{$_POST[savePost]}\">";
} else {
$savePost = htmlspecialchars(serialize($_POST));
echo "<input type='hidden' name='savePost'
value=\"$savePost\">";
}
}
?>
and when I load each page I call the function:
<?php
function restorePost() {
if (isset($_POST[savePost])) {
$_POST = unserialize(stripslashes(htmlspecialchars_decode($_POST[savePost])));
}
}
?>
That way if a user takes a long time doing something, they can re-authenticate and have their work
restored.
----
Server IP: 69.147.83.197
Probable Submitter: 144.17.3.197
----
Manual Page -- http://www.php.net/manual/en/function.serialize.php
Edit -- https://master.php.net/note/edit/98139
Del: integrated -- https://master.php.net/note/delete/98139/integrated
Del: useless -- https://master.php.net/note/delete/98139/useless
Del: bad code -- https://master.php.net/note/delete/98139/bad+code
Del: spam -- https://master.php.net/note/delete/98139/spam
Del: non-english -- https://master.php.net/note/delete/98139/non-english
Del: in docs -- https://master.php.net/note/delete/98139/in+docs
Del: other reasons-- https://master.php.net/note/delete/98139
Reject -- https://master.php.net/note/reject/98139
Search -- https://master.php.net/manage/user-notes.php