And if you don't want to add dependency on a whole framework just for that little bit of functionality? It's useful to know how to implement it on its own.
Not that it's bad to know how to do it yourself, but I'd make sure my implementation was sound before sharing it as advice.