#!/usr/local/bin/perl
# redirect.pl - web cgi routine to set cookie values and return
#
# Momemtum Code Generator - 5/22/2004
# dgs@accelix.com
#
# Copyright
# ---------
# Copyright(c) 2004, Accelix LLC. All Rights Reserved.
#
# Description
# -----------
# This program redirects back to the calling routine in order to set the
# value of one or more cookies. This is the only way you can set a cookie
# and allow it to be read immediately by the program that originally set it.
#
# RCS Information
# ---------------
# $Id$
# $Log$
#
# package main;
use strict 'vars';
use strict 'subs';
#use warnings;
#use diagnostics;
# load application modules
use cart; # application support module
# ---------------------------
# DECLARATIONS AND PROTOTYPES
# ---------------------------
# local variables
my %fm1 = (); # data from form (name/value pairs)
my $vsep = "?"; # url value separator
my $url = ""; # redirection url for return
my $val = ""; # form parameter
my $x = ""; # loop iterator
###
### START PROGRAM
###
# initialize the program
%fm1 = ReadForm (); # read the form (if any)
# add a redirection indicator
$fm1{redir} = 1 unless defined $fm1{redir};
# $url = $ENV{HTTP_REFERER};
$url = "/cgi-bin/webscr";
foreach $x (keys %fm1) {
$val = EncodeHTML ($fm1{$x});
$url = "${url}${vsep}${x}=${val}";
$vsep = "&";
}
# create a page with a tage that redirects back
DisplayHeaders ();
print <