Authentication function working for php rest server