Change CakePHP default routing after login

Reading time ~1 minute

This is coming directly from here. That website is out of date, and so here it is, v2.0 fresh.
I am assuming you understand routes.

In your bootstrap.php file add the following. This will instantiate CakeSession (after it's inclusion), from there you can check the status of the login and define the routes based on whether the user is logged in or not.

<?
// include the Session Component to our application
App::uses('CakeSession', 'Model/Datasource');
// now create new SessionComponent instance
$Session = new CakeSession();
// check if the user logged in
if ($Session->read('Auth.User')) {
    // set the default routing to submissions controller
    Configure::write('Route.default', array('controller' => 'users', 'action' => 'index'));
}
// nope, user not logged in
else {
    // set the default routing to our login page in users controller
    Configure::write('Route.default', array('controller' => 'pages', 'action' => 'display', 'home'));
}
and make sure this is in your routes.php file. Comment out or remove the old line.
<?
Router::connect('/', Configure::read('Route.default'));

Asyncio Basics Python 35

# Asyncio basics in pythonPython 3.5 brought with it asyncio. An event loop based paradigm previously available as a library but now it i...… Continue reading

Quick Laravel/Lumen install with Docker!

Published on March 02, 2016

PHP To Python

Published on February 24, 2016