The Yaws session server is ideal (and recommended) for maintaining cookie state in a server side application.
The code in session1.yaws shows a minimalistic way to handle sessions. To run it click here
The actual session API is documented in the man page for yaws_api.