I am creating a web service for login and register, but I want a single URL for register and login so that, when a user registers, it will automatically log in. No need for two services for register and login.

How can I get this?

1 Answer 1


When user gets saved in DB using user_save() it returns the user object. All you have to pass it to $GLOBAL['user']; and save session

   //Here is your previous code I assume where you have user_save()

   $user = user_save($userData);

   if($user) {
        $GLOBALS['user'] = $user;

Hope this may help you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.