I would like to use Services to programmatically login a user from another website.

So for example if site.example.com uses the services login endpoint on example.com in Chrome, when that user moves over to example.com they will already have a valid session and cookie for accessing the site.

I have looked into adding the cookies.txt file via my CURL request, and have tried the various different Drupal authentication method like user_login_submit() and drupal_session_regenerate() but none of them are working.

When i navigate over to example.com the user is still seen as being anonymous.

1 Answer 1


Just for anyone who is looking to implement something similar, i done this using a http redirect to an authentication page, passing and authenticated using the token generated from drupal_get_token() (important not to use the session id).

The important steps to follow are to override the GLOBAL $user with the newly generated session user details and then regenerate the session using drupal_session_regenerate().

  • I'm facing the exact same issue. I've trying to login a user to another site via services and the login goes fine via drupal_http_request, but I need the browser to also know that this user is logged in to that site already when they visit the site. Would appreciate it if you could share a bit more info or code samples. Thanks.
    – SN_26
    Nov 16, 2016 at 12:44

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.