Cannabis isn't exactly legal in amsterdam, it is decriminalized. Coffee shops can only have and sell limited amounts to customers and im sure they have to check if you're 18 before selling you anything, and would notice if someone bought you a joint and you smoked it in the cafe.