Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

 1 Answer(s)

  • Drupal's Service module provides resources to implement these kind of APIs. You can use Service module and enable its in-build login/logout resource.

    Please follow these steps to implement login validation using JS from Phonegap, Sencha or any other remote application:

    1: Install and enable Service module.

    2: Create a service endpoint and add its path.

    3: In resource tab select Checkbox for User (login and logout).

    4: Enable REST Server Response Formatters & Request Parsing

    5: For testing a Resource from Drupal Services, install poster in firefox and check your added service:- Tool->poster

    URL: http://localhost/my_drupal_site/?q=/system/connect.json

    Content Type: application/x-www-form-urlencoded

    Actions: POST

    6: If connection establish then process to step 7 otherwise check you connection.

    7: Create the simple php login page in remote application and call following javascript to make an ajax call:

      try {
          url: "",
          type: 'post',
          dataType: 'json',
          error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert('page_dashboard - failed to system connect');
          success: function (data) {
            var drupal_user = data.user;
            if (drupal_user.uid == 0) { // user is not logged in, show the login button, hide the logout button
            else { // user is logged in, hide the login button, show the logout button
      catch (error) { alert("page_dashboard - " + error); }

    This is just a jQuery code and can be used in any remote application which use jQuery. I hope this will help you.

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: