3 # Copyright (C) 2007 Jason Woofenden
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # require_once() this file instead of messages.php if you'd like to store
20 # save/restore messages in the session accross redirect()s. That's all you have
21 # to do. These functions are called when needed (from redirect() and
22 # display_messages()) if they are defined.
24 # see messages.php for documentation on how to use it.
26 require_once(__DIR__.'/'.'session.php');
27 require_once(__DIR__.'/'.'messages.php');
29 function session_save_messages() {
30 if(!isset($GLOBALS['wfpl_messages'])) {
33 if(!is_array($GLOBALS['wfpl_messages'])) {
36 if(!count($GLOBALS['wfpl_messages'])) {
41 session_set('wfpl_messages', json_encode($GLOBALS['wfpl_messages']));
44 function session_restore_messages() {
45 if(session_exists()) {
46 $messages = session_get('wfpl_messages');
47 if($messages !== false) {
48 session_clear('wfpl_messages');
49 $messages = json_decode($messages, true);
50 if ($messages !== null) {