Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Is it safe to manually sign a user in using AJAX?

Assuming you do not do stupid things, and use properly the relevant API, an AJAX login form can be as secure as the “core” login form.

The way you transfer the data is not very important by itself. Even HTTP, although people and google will claim as being insecure, can probably be secure enough with 2FA, one time passwords, or just use your own cellular connection instead of coffee shop/work WiFi/network. In any case this is up to the site’s owner to decide.

As for point 3, wp_signon is the right one and from there all the authentication and setting of cookies should be done.

One thing to keep in mind when doing AJAX, is that a successful login will not by itself reflect the new status in the UI without some extra work, and the easiest path is probably to just refresh the page which makes the whole AJAX idea much less appealing.

Another obstacle you will face is error reporting, like user/password mismatch, you will need to make a way to transfer the login errors to the front-end and make it in a generic enough way to let other login related plugins to add their own errors.

If it sounds like I am against login via AJAX, I guess I am, but this is just a personal opinion, there is nothing technically impossible or insecure about it.

Related Posts:

  1. WordPress Ajax Data Security
  2. wp_set_auth_cookie() doesn’t work in Ajax call
  3. Nonces and Cache
  4. Is it safe to assume that a nonce may be validated more than once?
  5. Multiple ajax nonce requests
  6. WordPress AJAX Login Screen
  7. Detecting post type within init action
  8. WordPress Ajax Login without page reload
  9. WordPress Nonce Issue for Ajax Login and Logout
  10. How can I automatically login using a URL?
  11. how to use reCaptcha v3 in wordpress custom login form?
  12. Nonces, AJAX, script variables & security in WordPress
  13. How do I check if AJAX nonces are implemented correctly?
  14. WP Admin AJAX Security – using POST to include a relative URL
  15. ajax nonce verification failing
  16. Why a strange discrepency between get_current_user_id() when using AJAX versus output of document.cookie?
  17. Should I check for privileges before hooking into `wp_ajax_$handle` or after?
  18. Ajax login without redirect/reload
  19. Is it secure to use admin-ajax.php in front?
  20. Interim-Login form on frontend
  21. Custom Login with Ajax not working with IE
  22. Why does check_ajax_referer give a 403 error on https websites?
  23. Using nonce when loading posts with AJAX
  24. 200 return code on ‘POST /wp-admin/admin-ajax.php’ while NOT logged in
  25. Custom RPC end-point security best pratice?
  26. Should wordpress nonce be placed in html form or in javascript file
  27. jQuery.post returns 0
  28. Ajax login fails: script sets cookies, but is_user_logged_in() returns false
  29. How to prevent my external API call from being called by anyone but me (my site)
  30. check_ajax_reffer not working when logged
  31. WordPress custom ajax login not working on mobile browsers
  32. How to safely pass post_id and user_id via AJAX to the backend (prevent user from changing it via JS)?
  33. Ajax Security regarding user priviliges and nonces
  34. Can I make an ajax response cross-domain?
  35. How to stop a nonce from being cached in an inline script, or alternatives to regenerate it if expired?
  36. I’m trying to register with AJAX
  37. How does the security of admin_ajax.php work?
  38. nonce_user_logged_out to assign guests unique nonces breaks ajax calls
  39. Nonce verification problem when logging in after a logout
  40. PHP “php://input” vs $_POST
  41. Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX
  42. Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
  43. Access-Control-Allow-Origin error sending a jQuery Post to Google API’s
  44. How to solve the error “SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.” in IE
  45. Show spinner GIF during an $http request in AngularJS?
  46. Refresh HTML Page in Browser Automatically on Timer – Every 15 Min
  47. JavaScript implementation of Gzip
  48. jQuery: Performing synchronous AJAX requests
  49. ASP.NET MVC controller actions that return JSON or partial html
  50. jQuery’s .on() method combined with the submit event
  51. Ajax takes 10x as long as it should/could
  52. How to check if I am in admin-ajax.php?
  53. What’s the easiest way to stop WP from ever logging me out
  54. Is there any way to rename or hide wp-login.php?
  55. Best way to end WordPress ajax request and why?
  56. How to load wp_editor() through AJAX/jQuery
  57. Increase of failed login attempts, brute force attacks? [closed]
  58. How does admin-ajax.php work?
  59. How to cache json with wp-super cache
  60. Load minimum WordPress environment
  61. Why use wp_send_json() over echo json_encode()?
  62. Why use admin-ajax.php and how does it work?
  63. How to get a unique nonce for each Ajax request?
  64. Open a Thickbox with content trough AJAX
  65. Initialize TinyMCE editor / visual editor after AJAX insert
  66. Why not register shortcodes if is_admin dashboard?
  67. WordPress AJAX with Axios
  68. Why is die() used at the end of function that handles an Ajax request?
  69. Why might a plugin’s ‘do_shortcode’ not work in an AJAX request?
  70. Making my AJAX powered WordPress Crawlable
  71. Is there a JavaScript API? How to access public and private data in JS?
  72. Get Previous & Next posts by Post ID
  73. failed to load wp-admin/admin-ajax.php
  74. Using Backbone with the WordPress AJAX API
  75. Using Ajax with a Class file
  76. Ajax in a settings page (update_option is undefined)
  77. How to pass data parameter to ajax action function handler
  78. Nonces can be reused multiple times? Bug / Security issue?
  79. Displaying PHP Errors from admin-ajax.php
  80. Can someone explain what wp_session_tokens are, and what are they used for?
  81. Adding “Remember Me” in custom login
  82. gettext does not translate when called in ajax
  83. Execute one AJAX request after another AJAX request finished
  84. WP-AJAX vs WP REST API: What to use for requests to the website from outside?
  85. Ajax and autocomplete
  86. How can I make an Ajax login form work with FORCE_SSL_ADMIN enabled?
  87. How to add to cart via AJAX Woocommerce [closed]
  88. SSL breaks customizer: page isn’t returned from ajax
  89. Why is a 500 error generated by admin-ajax.php not going into the Apache error log?
  90. Are ‘wp_ajax’ and ‘wp_ajax_nopriv’ exclusive to authenticated and non-authenticated users?
  91. How to HTML5 FormData Ajax
  92. admin-ajax.php vs Custom Page Template for Ajax Requests
  93. How to override WP_DEBUG for Ajax responses?
  94. Stop admin-ajax?
  95. redirect out of wp-admin, without losing admin-ajax.php
  96. Call to undefined function add_action()
  97. How to fake a WordPress login?
  98. Limiting sessions to one IP at a time
  99. How build a custom login/register form with error handling?
  100. Including WordPress in RESTful API
Categories ajax Tags ajax, login, security
Inconsistent behavior from number_format
Encrypt / Decrypt Post Title and Details

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress