This may sound a bit naive questions as i am a beginner. But I do my best to put it into words. You may have experience when sometimes you want to use the internet in a cafe for example (with your wifi device ofcourse), when you click on the desired network, you will be redirected to a log-in page to insert a username and password. Is this a specific app? what is this app (functionality) called? Is it commercial or is there any open-source projects that can be used? Thank you.
There are any of a number of different ways to do this. Many options, both open-source and proprietary will handle it. I know DD-WRT is one example of an open source router firmware which provides this kind of functionality directly. Behind the scenes, what is basically happening is that any connection that is made to the device gets routed to a special network where any request will resolve to an HTTP redirect to the login page. Once login is done, the router tracks the MAC address of the device that is allowed access and redirects it to the network that is actually connected to the network or Internet.
A similar type of goal can be accomplished for private networks using WPA-Enterprise which would require an actual username and password to be configured in the wifi connection itself, though WPA Enterprise is not what you are directly talking about since it doesn't use an open wifi connection. It is, however, more secure since it gives each user their own user specific encryption and thus multiple users can not eavesdrop on each other.