Got CGISESH working. Simple demo.

=> tilde.cafe/~stack/cgisesh/live/cgitest

Click on the link; the cgi will keep track of how many times you visit (refresh to see the counter go up). If my cgisesh server is running, of course.

This simple cgi uses cgisesh to keep session information for each user (visit count in this simple example). cgisesh is a minimal in-memory key-value server designed to provide per-user session data for Gemini CGI scripts.

There is still some work to do, but as a first round it's not bad. It makes it trivial to keep session state for games.

=> https://tildegit.org/stack/cgisesh

Here is the source, BSD 3-clause license.

I will work on error-proofing and probably some optimizations (right now it's just a linear search, although in memory and with tens or hundreds of unique users is probably faster than databases...)

The interface is dead simple:

void cgisesh_init(int RecSize,char* SocketPath);
int  cgisesh_lookup(char* sha256, void*buf);
int  cgisesh_update(void*buf);

My original announcement with project details and rationale

=> gemini://bbs.geminispace.org/u/stack/17006

=> ๐Ÿš€ stack

2024-05-17 ยท 9 months ago ยท ๐Ÿ‘ skyjake, corscada

4 Comments โ†“

=> ๐Ÿ€ gritty ยท 2024-05-17 at 18:01:

it shows my hash but I get an error: 111

=> ๐Ÿš€ stack [OP] ยท 2024-05-17 at 19:13:

@gritty, the server is not up at the moment. The hash is just from the CGI...

=> ๐Ÿš€ stack [OP] ยท 2024-05-17 at 19:20:

@gritty: back up... I started 'server' from an ssh command line and it was killed when my session disconnected. It's just a toy for now, obviously it needs to run as a daemon, or at least in a tmux session!

=> ๐Ÿ€ gritty ยท 2024-05-19 at 01:52:

I don't know much about SCGI but what I read is that one server is started for all incoming requests and uses sockets. I know molly brown supports it.

do you think an SCGI server could hold sessions in memory like this?

Proxy Information
Original URL
gemini://bbs.geminispace.org/u/stack/17032
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
82.859217 milliseconds
Gemini-to-HTML Time
0.754484 milliseconds

This content has been proxied by September (3851b).