#!/usr/bin/perl ############################################################ # &outputDebug(); # uncomment this to enable debug mode output ############################################################ # name: Cookie # author: Ian Hickson # license: GPL # description: Primitive cookie tests ############################################################ # Initialise System use lib '../utils'; use strict 'vars'; $output::mediaPath = '../../../media/'; $output::appName = 'Cookie Tester'; $output::authorContact = 'http://www.bath.ac.uk/%7Epy8ieh/'; $output::authorName = 'Ian Hickson'; $output::authorEmail = 'py8ieh=website=cgi=development=tests=cookies\@bath.ac.uk'; require 'inputRoutines.pl'; # get cookies, parameters require 'outputRoutines.pl'; # so that we can output stuff ############################################################ my $ok = 1; my $bad = 2; if ($param::set) { if (($param::name ne '') and ($param::value ne '')) { &output::addCookie($param::name, $param::value); $param::set = $ok; } else { $param::set = $bad; } } &output::printHTMLHeader(); if ($param::set) { if ($param::set == $ok) { print '

Cookie set ('.$param::name.'='.$param::value.').

See if it worked...

Set Another Cookie!

'; } else { print '

Make sure you fill in both fields fully, please. (Or, you can just see what cookies are currently being sent.)

'; } } else { if (keys %input::cookies > 0) { print '

The following cookies were returned:

'; } else { print '

Your browser returned no cookies this time.

'; } print '

Set A Cookie!

To add a cookie, use this form.

'; } &printSetCookieForm(); &output::printHTMLFooter(); ############################################################ sub printSetCookieForm { print '
  1. Cookie Name:
  2. Value:
'; }