camelcity.com
The power behind the pages
888-229-3255

Sample Cookie, Form, and URL Input Script

This script demonstrates handling input to CGI scripts in a convenient and consistent way. All of the Form, URL, and Cookie input is processed and placed into an array. To send information to this script, use one of the following methods:

1. Use a FORM input field, and POST the form.

2. Use a URL query string when retreiving this script. For example, call the script as:
http://www.camelcity.com/example-cgi/cookie.cgi?example=a
to set a variable called "example" equal to "a"

3. Use a cookie. To set a cookie, call this script with the query string "setcookie=value". For example:
http://www.camelcity.com/example-cgi/cookie.cgi?setcookie=a
will set the ExampleCookie equal to a. This script only uses one cookie as an example. By changing the source code, you can assign other cookie values as needed.


Here are all the Form, URL, and Cookie values passed into this script:


Here is our environment:

DOCUMENT_ROOT=/var/www/host-248
HTTP_ACCEPT=Accept: application/xhtml+xml,text/html;q=0.9,text/plain;
HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7
HTTP_ACCEPT_ENCODING=gzip
HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5
HTTP_CACHE_CONTROL=no-cache
HTTP_CONNECTION=close
HTTP_HOST=www.camelcity.com
HTTP_PRAGMA=no-cache
HTTP_USER_AGENT=CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
HTTP_X_CC_LIST=List:1 For:24.199.229.189
PATH=/bin:/usr/bin:/sbin:/usr/sbin
REMOTE_ADDR=38.103.63.60
REMOTE_PORT=55794
SCRIPT_FILENAME=/var/www/host-248/example-cgi/cookie.cgi
SERVER_ADDR=192.168.8.248
SERVER_ADMIN=noel@ncmusic.com
SERVER_NAME=www.camelcity.com
SERVER_PORT=80
SERVER_SIGNATURE=
SERVER_SOFTWARE=Apache/1.3.34 (Debian) PHP/4.4.4-8+etch6 mod_perl/1.29
UNIQUE_ID=Sk6N0sCoCPgAABICcOI
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
REQUEST_METHOD=GET
QUERY_STRING=
REQUEST_URI=/example-cgi/cookie.cgi
SCRIPT_NAME=/example-cgi/cookie.cgi

Source code for this script

Copyright © 1995-2002 camelcity.com PO Box 17383 Winston-Salem, NC 27116-7383. All content on these pages is distributed under the GNU Public License unless otherwise noted. Information is for entertainment purposes only. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "camelcity.com" and "The Power Behind the Pages" are trademarks of camelcity.com. Other trademarks shown are trademarks of their respective owners. | Privacy Policy | Content Rating