note 98139 added to function.serialize

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.