I’ve written a C/CGI web application for booking items. My client has requested that I add an ‘admin’ feature where an authorised user can delete and change data, and those who aren’t, can only add data. It is much simpler in concept than most login implementations as there is only a password, and effectively only two states, ‘anonymous’ and ‘admin’.
I come from a PHP background where session management is as simple as session_start(), and I can instantly play around with $_SESSION. Of course, in C/CGI there is nothing built-in like that. I would like to avoid adding a CGI library dependency (I already depend on glib, confuse and libmysqlclient, plus I’m curious to learn about session management).
What is the simplest way to do a password-based session management in C/CGI, without the need for multiple users, large amounts of session data, or anything complex?
A session implies server side maintained state. As you don’t have users I guess you want it simpler. If that is the case a signed cookie with an expiration date can do it. This tutorial will show how to do it with Python:
http://webpython.codepoint.net/cgi_cookie