Shopping Cart Scripts

CGI shopping cart scripts: how server-side e-commerce worked and when it still applies

How did CGI shopping cart scripts manage cart state without a database?

Classic CGI shopping cart scripts stored cart contents in hidden form fields, cookies, or flat text files on the server, keyed by a session token passed between pages. Each page request ran a CGI script that read the session file, applied any changes (add, remove, update quantity), wrote the session back, and returned the next cart page. No persistent server-side process was involved; every request was a fresh script execution.

Request custom development Getting started

How session state worked in CGI carts

A persistent process like a database or application server holds state in memory between requests. CGI scripts do not: each request forks a new process, runs the script, and exits. Cart state had to live somewhere between requests. The two common approaches were cookies (storing the cart contents or a session token in the browser) and server-side session files (storing cart data in a temp file named by a unique session ID, with the ID passed in a cookie or hidden form field).

Killercart, the CGI shopping cart product sold on this domain in the late 1990s, used a server-side session file approach. Each visitor got a session ID in a cookie; the script read the session file, updated it, and wrote it back on every cart interaction. The product catalog was typically a flat tab-delimited file the script read on each request. No SQL database was required, which was an advantage on shared hosting environments of the era where MySQL was not always available.

Security concerns specific to CGI carts

Storing prices in hidden form fields and trusting them on the order submission page was a common early mistake. An attacker could edit the form before submitting, change the price of every item to zero, and generate a zero-dollar order. The fix is to store prices server-side and look them up by product ID on order submission, never accepting a price the browser sends as authoritative.

Session file management also needs care: session files must be stored outside the web root, session IDs must be long and random enough that they cannot be guessed, and old session files must be cleaned up to prevent disk space exhaustion. PHP solved many of these problems by building session handling into the language runtime; CGI scripts have to implement each safeguard explicitly.

When a custom CGI cart still makes sense

For most new e-commerce projects, a dedicated platform (WooCommerce, Shopify, Stripe Checkout) is the right answer. They handle payment card security, PCI-DSS compliance, tax calculation, inventory, and fulfillment integration. Building a custom CGI cart means owning all of that yourself.

There are narrow cases where a minimal CGI order script is still appropriate: a simple request form that does not process payment directly (sends an order inquiry for manual invoicing), an internal tool where PCI scope is not a concern, or a site that already has a CGI stack for other reasons and needs a lightweight add-to-cart for a small product catalog. In all of these cases, the CGI script is a form handler that emails an order summary rather than a true payment processor.

What to know

Key points

Get help

Listings and a local agent, when you are ready

Need a CGI script built, debugged, or a hosting environment configured? Forms use a clearly-marked placeholder endpoint until wired to a real system.

Hosting partner CGI-compatible hosting for e-commerce

Reserved for an affiliate link to a vetted shared or VPS hosting provider that supports CGI and Perl/Python execution. Operator wires affiliate link here.

Development Need a custom CGI script built?

Self-hosted lead form for custom CGI development inquiries. Placeholder endpoint until wired to the operator's CRM or email handler.

Open inquiry form →

Custom CGI development

No spam. Your inquiry is answered within 1 business day.

Hosting setup help

No spam. Your inquiry is answered within 1 business day.

Questions

Frequently asked questions

How did CGI shopping carts work without a database?
They stored cart state in flat files on the server, keyed by a session ID passed to the browser in a cookie. Each CGI request read the session file, applied the change, wrote the file back, and returned the updated page. The product catalog was also a flat file the script read on every request. No SQL was required, which made them popular on shared hosting where databases were not always available.
Should I build a new e-commerce site with CGI?
For most projects, no. Dedicated e-commerce platforms handle payment security, PCI compliance, tax, inventory, and fulfillment in ways that would take significant effort to replicate in a custom CGI script. A CGI script is appropriate for a simple order inquiry form that does not process payment directly, but for anything involving live payment card processing, use a platform designed for that purpose.

CustomCGI publishes reference information on CGI programming and server-side web scripting for educational and informational purposes. Code examples are provided as-is for learning; always audit and test scripts in a staging environment before deploying to production. Security vulnerabilities in CGI scripts are a real risk; follow current best practices and review the security guide before deploying any user-facing code.