I once have left some similar code in my final delivered code base. I have used that to login to any user account while testing and moved it to new url known only to me with some password protection while delivery, so that i can login to system anytime i need :P
This was my personal freelance project and I was the only developer/person interacting / involved with them.
PS : This is not ethical and not advised. If you are working for some corporation then don't do it until your manager/ company asks you to do this. You will surely get fired if caught.