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

  • Home
  • SEARCH
  • 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 7489479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:15:13+00:00 2026-05-29T15:15:13+00:00

I am trying to set up a view for my logged in user. I

  • 0

I am trying to set up a view for my logged in user. I lifted the code from the cakephp 2.0 manual. this is the controller code:

public function view($id = null) {

    $this->User->id = $id;
    if (!$this->User->exists()) {
        throw new NotFoundException(__('Invalid user'));
    }

    $this->set('user', $this->User->read(null, $id));
}

When a user with the user_id of 1 logs in, cake doesn’t go to /users/1. Instead it just goes to /users/view. Here are the routes pertaining to the users controller:

Router::connect('/users', array('controller' => 'users', 'action' => 'login'));
Router::connect('/users/:action', array('controller' => 'users'));
Router::connect('/users/:id', array('controller' => 'users', 'action' => 'view'));

I’m not sure which I have wrong, the route code or the controller code.

UPDATE New controller function:

public function view($id = null) {

    $this->User->id = $id;
    if (!$this->User->exists()) :
        throw new NotFoundException(__('Invalid user'));

    elseif($this->Auth->login()) :
return $this->redirect(array('controller' => 'users', 'action' => 'view', AuthComponent::user('id')));

    endif;
    $this->set('user', $this->User->read(null, $id));
}
  • 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-29T15:15:14+00:00Added an answer on May 29, 2026 at 3:15 pm

    The page Cake opens after a succesful login is either the page the unauthenticated user tried to open initially or the action set in the loginRedirect property of your Auth component in the (App)Controller. As also documented here. In other words, the above code has nothing to do with the behaviour you are describing/requesting.

    In this case, since the user_id is only available after a successful login (and thus cannot be set in the loginRedirect), you’ll need to adjust your login action in your UsersController instead, to become something along the lines of:

    if ($this->Auth->login()) {
        return $this->redirect(array('controller' => 'users', 'action' => 'view', AuthComponent::user('id'));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set up a Navigation View where a user can enter
I'm trying to set the image of a new view. I set the controller's
I am trying to set the background image of my view controller based on
Hi all I am trying to set up a view that lets the user
I am trying to set Padding Top to Specified View from another Layout Height
I'm trying to set a gradient background on a view, but my code below
I am trying to set up a view to received a JSON notification from
I am trying to set accessory view of cell which is UIButton . But
I'm trying to use coffeekup as my default template app.set 'view engine', 'coffee' app.register
I am trying to set up a simple single-view iOS5 iPhone application (with AppDelegates,

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.