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

Can we start session from another php site to wordpress blog site?

I found the solution for using below function:

    function auto_login() {
        // make sure user is not logged in and "user" was POST'd
        $username = isset( $_POST['user'] )? $_POST['user'] : false;
        if ( ! is_user_logged_in() && $username ){
            // load the user by username
            $user = get_user_by( 'login', $username ); 
            if ( $user ) {
                // log user in using the $user object properties
                wp_set_current_user( $user->ID, $user->user_login );
                wp_set_auth_cookie( $user->ID );
                do_action( 'wp_login', $user->user_login );
            }
        }
    }

add_action( 'wp_loaded','auto_login' );

Related Posts:

  1. Can I programmatically login a user without a password?
  2. What is $interim_login?
  3. Adding extra authentication field in login page
  4. What exactly is ReAuth?
  5. Login members using web services
  6. Disable WordPress 3.6 idle logout / login modal window / session expiration
  7. How to pass users back and forth using session data?
  8. Need to execute a cron job
  9. how to update current logged user username
  10. Validate Custom Login field
  11. Calling wp_signon doesn’t log the user in
  12. How to implement Google reCaptcha without installing a plugin?
  13. Is it possible a one click user registration with Facebook or Twitter (or other Social Networks)?
  14. Are there ways of logging in that bypass wp-login.php altogether?
  15. How to display username and password after registration
  16. Two factor authentication
  17. How to generate “WP_Error” Object for user login?
  18. Allow Access to Home Page and Login Screen but Nothing Else (unless logged in)
  19. Where is the php file, that does the checks for login information?
  20. I want login using email not username wordpress front end
  21. Reloading page with a query string upon login for admins
  22. WordPress authentication using custom php?
  23. authenticate user without redirecting
  24. Multiple issues with Ajax login function due to browsers and cookies
  25. How to post frontend login form to a different authentication script from wp-login?
  26. Custom user roles are unable to login
  27. Using WordPress login for a non word-press website
  28. Extend Cookie with auth_cookie_expiration not working
  29. Opening protected page with cookie?
  30. Handle POST request sent from an external site for login?
  31. External Authentication
  32. Login and register by API
  33. In Django, how do I know the currently logged-in user?
  34. Can’t log in: “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”
  35. Is there any way to rename or hide wp-login.php?
  36. How to login with email only no username?
  37. How can I redirect user after entering wrong password?
  38. Increase of failed login attempts, brute force attacks? [closed]
  39. Login page ERROR: Cookies are blocked due to unexpected output
  40. Separate registration and login for different roles
  41. SSO / authentication integration with external ‘directory service’
  42. Preventing session timeout
  43. How reduce wordpress login session timeout time?
  44. How to prefill WordPress registration with social details
  45. Check for correct username on custom login form
  46. How to Change the Default Home Page for the WordPress Dashboard?
  47. Disallow user from editing their own profile information
  48. I can’t access my site via wp-admin
  49. ‘Password field is empty’ error when using autofill in Chrome
  50. Removing username from the ‘wordpress_logged_in’ cookie
  51. How to show ‘login error’ and ‘lost password’ on my template page?
  52. How do I require authorization / login to view a specific set of posts / pages?
  53. Custom login form
  54. How to prefill the username/password fields on the login page
  55. wp_signon returns user, but the user is not logged in
  56. Prevent wp_login_form() from redirecting to wp-admin when there are errors
  57. Redirect user using the ‘wp_login_failed’ action hook if the error is ’empty_username’ or ’empty_password’
  58. wp_signon() does not authenticate user guidance needed
  59. What are the differences between wp_users and wp_usermeta tables?
  60. WordPress auto login after registration not working
  61. Make my wordpress blog remember my login “forever”
  62. How to check in timber if user is loggedin?
  63. How do I change the language of only the login page?
  64. Stop WordPress from logging me out (need to keep me logged in)
  65. Woocommerce registration page [closed]
  66. How to disable autocomplete on the wp-login.php page
  67. Share login data/cookies between multiple installations
  68. Synchronize WordPress user accounts across multiple domains and installations without using WordPress MU
  69. How do I change the logo on the login page?
  70. Why does WordPress hide the reset password key from the URL?
  71. Is it possible to sign in with user_email in WordPress?
  72. How to use current_user_can()?
  73. Avoid to load default WP styles in login screen
  74. WordPress registration message
  75. How to fake a WordPress login?
  76. how to display the wordpress login and register forms on a page?
  77. Does wp_logout_url() destroy a session? (Logging out question)
  78. How can I send a welcome email to a user AFTER they login for the first time?
  79. Can not login with correct username and password
  80. Website Visible only to Registered users
  81. How can i increase the login expiration length?
  82. How do I use add_action from a class method?
  83. How to remove the WordPress logo from login and register page?
  84. How can I add a custom script to footer of login page?
  85. Brute force attack?
  86. Customize wp_new_user_notification_email()
  87. How to check WordPress website username and password is correct
  88. Login email after registration never sent or received
  89. How can I create a separate blog that is private?
  90. How to keep always logged in development environment
  91. Add Confirm Password field in wp-login.php Password Reset page
  92. Integrate recaptcha and wp_signon – what is needed?
  93. Log in from one wordpress website to another wordpress website
  94. Stop users from logging in from multiple locations
  95. I want to disable E-Mail verifcation / activation when a user signs up for my WordPress site
  96. custom login page redirect to logged in user profile page
  97. Email address or username used to login in wordpress
  98. How do I check if a post is private?
  99. Front-end login: Redirect user to the post they had created
  100. Receiving “This content cannot be displayed in a frame” error on login page
Categories login Tags authentication, login
In admin manage users page, how can I stop users with certain privileges from editing users with other privileges?
Theme option page doesn’t save options

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
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 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