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 8963657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:24:19+00:00 2026-06-15T16:24:19+00:00

Is it possible in CakePHP 1.3 to login a user by indicating the user’s

  • 0

Is it possible in CakePHP 1.3 to login a user by indicating the user’s id in the users table?

Now, to do a “manual” login, I do this (which works):

$this->data['User']['username'] = username;
$this->data['User']['password'] = password;
$this->Auth->login($this->data);

I would like to be able to indicate the specific user, for example adding $this->data[‘User’][‘user_id’] before the login() function. (I’ve tried that but it doesn’t work).

The reason I want to do this is because in the users table there are different users records of users who have the same username and password. It seems odd but in my case makes sense, since one same user may create several accounts for different reasons, and he may choose the same username/password.

Any ideas would be much appreciated!

EDIT:

I’m going to give a specific example of what I’m trying to do, maybe it helps to bring some ideas.

Say I have this 2 records in the users table (fields are user_id / username / password / account_id):

  • Record 1: 1 / johndoe / password1 / 10
  • Record 2: 2 / johndoe / password1 / 15

So this 2 records have same username and password, but different user_id and account_id. When the login is processed, I know what account_id the user has chosen. So I want to log in the corresponding user. So if the user chooses account 15, then logs is, I should be logging in the user with id 2.

However, the way cake’s login works, it always retrieves the first record that matches username / password. In this example, cake would be logging in the user with id 1.

Is there any way I can do what I want?

  • 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-06-15T16:24:20+00:00Added an answer on June 15, 2026 at 4:24 pm

    Doesn’t sound like a very good idea to me, but if you really want/must do it that way, then have a look at AuthComponent::userScope. You can use it to define additional conditions for authentication lookups, for example:

    $this->Auth->userScope = array('User.account_id' => 15);
    

    That way authentication would only be successful when username and password match and the users account_id is 15, ie the resulting query would look something like this

    User.username = 'abc' AND User.password = 'xyz' AND User.account_id = 15
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: CakePHP Subscribe Users Model I have three models User Post Friendship What
Is it possible to create/extend a CakePHP Exception handler which shows the url the
This is essentially the same question as CakePHP: Is it possible to insert record
Is it possible in cakephp that a user be registered automatically with a predefined
I'd like to know whether it's possible to logout an user in CakePHP. I
In CakePHP, Is it possible to insert into another table with the other model
I wondered if this would be possible. I'd like to centralize my cakePHP core
I have a website already running made with CakePHP, which has its own login
I have a website made with CakePHP 1.3.7. This website has it's own login
Possible Duplicate: CakePHP: Call to a member function find() on a non-object I have

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.