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('code/wfpl/session.php');
27 require_once('code/wfpl/string_array.php');
28 require_once('code/wfpl/messages.php');
30 function session_save_messages() {
31 if(!isset($GLOBALS['wfpl_messages'])) {
34 if(!is_array($GLOBALS['wfpl_messages'])) {
39 session_set('wfpl_messages', array_to_string($GLOBALS['wfpl_messages']));
42 function session_restore_messages() {
43 if(session_exists()) {
44 $messages = session_get('wfpl_messages');
45 if($messages !== false) {
46 session_clear('wfpl_messages');
47 return string_to_array($messages);