3 # This program is in the public domain within the United States. Additionally,
4 # we waive copyright and related rights in the work worldwide through the CC0
5 # 1.0 Universal public domain dedication, which can be found at
6 # http://creativecommons.org/publicdomain/zero/1.0/
9 # require_once() this file instead of messages.php if you'd like to store
10 # save/restore messages in the session accross redirect()s. That's all you have
11 # to do. These functions are called when needed (from redirect() and
12 # display_messages()) if they are defined.
14 # see messages.php for documentation on how to use it.
16 require_once(__DIR__.'/'.'session.php');
17 require_once(__DIR__.'/'.'messages.php');
19 function session_save_messages() {
20 if(!isset($GLOBALS['wfpl_messages'])) {
23 if(!is_array($GLOBALS['wfpl_messages'])) {
26 if(!count($GLOBALS['wfpl_messages'])) {
31 session_set('wfpl_messages', json_encode($GLOBALS['wfpl_messages']));
34 function session_restore_messages() {
35 if(session_exists()) {
36 $messages = session_get('wfpl_messages');
37 if($messages !== false) {
38 session_clear('wfpl_messages');
39 $messages = json_decode($messages, true);
40 if ($messages !== null) {