When the iPhone locks (the screen turns off) it goes into power savings mode. Sometimes, because it does not always happen to mine, it re-connects to the wifi.
Now if this is an Internet cafe, yes you will need to login again, because the router will assign a new IP address to them - which brings me to my next point.
If an iPhone disconnects from the network the router releases that IP address and other devices can take its place. When the iPhone then reconnects it needs a new address. Some iPhones do this and others don't - it may depend on how many devices are connecting at any given time to your set up.
Short answer: nothing you can do about it - it's just the name of the game with wifi networks.
If however you have a regular device (say at home) you can assign it a dedicated IP address, but in an Internet cafe this is not relevant.
Hope this helps answering your question.