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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:42:42+00:00 2026-05-27T16:42:42+00:00

Im just wondering and curious about how to achieve dynamic routes configuration in cakephp,

  • 0

Im just wondering and curious about how to achieve dynamic routes configuration in cakephp, or as such that I can create two routes like so:

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

without trigerring the error everytime a user go to my site. What I want to do is to set ‘/’ as my default landing page when user is not logged in, but in other way if the user is logged in and Auth session is present, i would like to set the url to ‘/’ but pointing to user’s dashboard.

What I thought was importing session in routes.php will work but it was not the way I expected:

App::import('Session', 'Component');
$this->Session = new SessionComponent;

if($this->Session->check('Auth.User')) {
        Router::connect('/', array('controller' => 'users', 'action' => 'dashboard'));
} else {
    Router::connect('/', array('controller' => 'users', 'action' => 'login'));
}

Any help is greatly appreciated, im sure many of us are waiting also for the answer.
Thank you very much in advance.
And wishing u a Happy Holidays.

  • 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-27T16:42:43+00:00Added an answer on May 27, 2026 at 4:42 pm

    I would simply switch this on the controller level. Point your / route to UsersController::home, in there do:

    function home() {
        if ($this->Auth->user()) {
            $this->dashboard();
        } else {
            $this->login();
        }
    }
    
    function dashboard() {
        $this->render('dashboard');
    }
    
    function login() {
        $this->render('login');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wondering is it possible to build CLI app that can be run from
Just something that i was wondering about. In Europe the comma us mostly used
I'm just wondering about an implementation detail of Scala generics. In C# one can
just wondering when I had an iphone I was able to create a web
Just wondering if anyone can optimize this usortMonths() function to be better? Basically I
I've always been curious about this. Between the two code example which is more
I'm just curious about this, as it's probably too much trouble to be worth
Quite curious, but was just wondering if anyone knows the difference between using: System.Windows.Forms.SaveFileDialog
Just curious about something. While converting HTML colors (whose individual color components are represented
I am just curious about this. I had a network folder open on one

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.