Created
September 8, 2014 14:54
-
-
Save luiscoms/1dd5fee944b016623bcf to your computer and use it in GitHub Desktop.
Codeigniter Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
class Pages extends CI_Controller { | |
public function __construct() { | |
parent::__construct(); | |
session_name('lpi_luiscoms'); //load session name | |
session_start(); | |
} | |
public function index() { | |
$this->view('login'); | |
} | |
public function login() { | |
$this->view('login'); | |
} | |
public function logout() { | |
session_destroy(); | |
session_unset(); | |
$this->view('login'); | |
} | |
public function home() { | |
// Every method must do this | |
if (!isset($_SESSION['logged'])) { | |
redirect('login'); | |
} | |
// show home | |
$this->view('home'); | |
} | |
public function clients() { | |
// Every method must do this | |
if (!isset($_SESSION['logged'])) { | |
redirect('login'); | |
} | |
// show clients | |
$this->view('home'); | |
} | |
public function view($page = 'login') { | |
if ( ! file_exists('application/views/'.$page.'.php')) { | |
// Whoops, we don't have a page for that! | |
show_404(); | |
} | |
if (isset($_SESSION['logged'])) { | |
redirect('home'); | |
} | |
$data['title'] = 'Home'; // Capitalize the first letter | |
$this->load->view('templates/header', $data); | |
$this->load->view('home', $data); | |
$this->load->view('templates/footer', $data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment