Wifi Access Management, how do people usually implement it?

I'm at a coffee shop that includes a 4 hour wifi access code on their receipts. I am curious as to how this could be implemented. Specifically:

  • Where are the passwords stored? I assume there is a table in the router somewhere, but doubt that the router would generate the passwords or clean up this passwords periodically.
  • Is there a server that manages these lists, periodically deletes/inserts into the router's password table, and responds to requests for passwords?
    • If there is a server, how does the receipt printer interact with it (e.i. a simple http request?)
    • If there is a server, how does it communicate with the router?

I know there are many ways to do this, just looking for an overview of what could work.