Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 716359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:17:26+00:00 2026-05-14T05:17:26+00:00

I have been busy integrating WordPress to one of a CakePHP application.Last Monday I

  • 0

I have been busy integrating WordPress to one of a CakePHP application.Last Monday I cracked the way to integrate it.Now another problem I faced was that Client wanted to auto login the users who are login in CakePHP side,I did that too and it works fine in local.I am using the Session Variable of CakePHP which is set in core.php of cakephp,in the WordPress also.The Code snippet of the Auto Login plugin is : –

session_name("Cake_PHP_Session_Vars");
session_start();
function auto_login(){if (!is_user_logged_in()) {
    //determine WordPress user account to impersonate
    $user_login = 'guest';

   //get user's ID
    $sessVars = $_SESSION['User'];
    $user_id = $sessVars['id'];

    //login
    wp_set_current_user($user_id, $user_login);
    wp_set_auth_cookie($user_id);
    do_action('wp_login', $user_login);
}}add_action('init', 'auto_login');

It all works fine on the Local system but when I am putting it on Server,It is not working out.Please suggest me what could be the problem here.
Thanks In Advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:17:27+00:00Added an answer on May 14, 2026 at 5:17 am

    Well I rectified the problem I was facing.
    I was just setting up the current user’s from Cake Side to WP only through the User Id set in the Session variable.But there is a chance that incremented id’s in Cake’s User Table could be different and when we a are putting that into Wp_users table it could be different than that.so in the new plugin I just added some of the line in which retrieve the username of the Logged In user and then fetch the ID of that user,coz we know that there is 0 possibility of having two(or more) Users with same USERNAME.That’s why we then fetch the Id of the Username we have in the Session and then use

    wp_set_current_user($user_id, $user_name);
    

    You all can see that I have replaced $user_login (that was by default set to Guest) with $user_name(fetched from the Session Variable).Now it is working fine.The main issue was that in my Local system Cake’s Tables and WordPress tables were Synced very nicely,but in server there was some problem with the synchronization.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been busy with the cakePHP framework for a couple of months now
I've been busy with this for months now. I currently have 2 servers for
I have been busy in my project creating a webapp (in struts) that manages
I have been busy with a exercise where I need to compare a winning
I have a bachelor in computer science. And have been busy doing security research
$(#profile_bar).mouseover(function(){ <?php $_SESSION['sessionasdf'] = 'asdf'; ?> }); Hello! I have been busy with this
Recently I've been busy with some PHP framework - completely off-topic by the way.
I have been busy building the UI for a class file I wrote a
I have been busy setting up authentication, a JDBC realm in particular, on GlassFish
I have been busy creating an app for Red5. Imagine what was my surprise

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.