Skip to content

Commit 379db08

Browse files
committed
add another controler and navigation to check sesiondata example
* provide links and better view organization of the info * added new controler so user can navigate to check session data validity
1 parent 9ca42bd commit 379db08

File tree

4 files changed

+65
-5
lines changed

4 files changed

+65
-5
lines changed

webappweb/controllers/Indexhome.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function __construct()
1212
public function index()
1313
{
1414
$data = array();
15-
$data['viewtitle'] = 'index at Pagetest';
15+
$data['viewtitle'] = 'index at Indexhome index function';
1616
$this->load->view('header.php',$data);
1717
$this->load->view('homesview.php',$data);
1818
$this->load->view('footer.php',$data);
@@ -21,7 +21,7 @@ public function index()
2121
public function testfunct()
2222
{
2323
$data = array();
24-
$data['viewtitle'] = 'testfunc at Pagetest';
24+
$data['viewtitle'] = 'testfunc at Indexhome testfunct function';
2525
$this->load->view('header.php',$data);
2626
$this->load->view('homesview.php',$data);
2727
$this->load->view('footer.php',$data);

webappweb/controllers/Indexother.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2+
3+
class Indexother extends CP_Controller {
4+
5+
function __construct()
6+
{
7+
parent::__construct();
8+
$this->checksession();
9+
}
10+
11+
/** http://127.0.0.1/codeigniterpower/index.php/indexcontroler/index */
12+
public function index()
13+
{
14+
$data = array();
15+
$data['viewtitle'] = 'index at IndexOther at index';
16+
$this->load->view('header.php',$data);
17+
$this->load->view('homesother.php',$data);
18+
$this->load->view('footer.php',$data);
19+
}
20+
21+
public function testfunct()
22+
{
23+
$data = array();
24+
$data['viewtitle'] = 'testfunc at IndexOther at testfunct';
25+
$this->load->view('header.php',$data);
26+
$this->load->view('homesother.php',$data);
27+
$this->load->view('footer.php',$data);
28+
}
29+
}
30+
31+
/* End of file welcome.php */
32+
/* Location: ./application/controllers/welcome.php */

webappweb/views/homesother.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<h1>Welcome/Bienvenido a VNX Codeigniter</h1>
2+
<p >This is:</p>
3+
<?php
4+
$userdata = $this->session->userdata('userdata');
5+
6+
echo br().PHP_EOL; // genera neuva linea en codigo html al navegador
7+
echo form_fieldset('This is the view '.$viewtitle,array('class'=>'containerin ') );
8+
9+
echo '<div class="row"><div class="col-sm-4 col-sm-offset-4">';
10+
foreach ($userdata as $ukey => $value)
11+
{
12+
echo '<spawn class="btn btn-danger">'.$ukey.'</spawn>:'.$value;
13+
}
14+
echo '</div></div>';
15+
echo form_fieldset_close() . PHP_EOL;
16+
17+
echo 'Click here to test checksession on Home module/controller: '.anchor('Indexhome','<spawn class="btn btn-danger">Go to Indexhome</spawn>');
18+
echo br();
19+
echo 'Click here to test checksession on same controller but textfunct method: '.anchor('Indexother/testfunct','<spawn class="btn btn-danger">indexother/testfunc</spawn>');
20+
echo br();
21+
echo anchor('Indexauth/auth/logout','<spawn class="btn btn-danger">Logout</spawn>');
22+
23+
?>

webappweb/views/homesview.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55

66
echo br().PHP_EOL; // genera neuva linea en codigo html al navegador
77
echo form_fieldset('This is the view '.$viewtitle,array('class'=>'containerin ') );
8-
8+
echo 'User data from sesion checked: ';
99
echo '<div class="row"><div class="col-sm-4 col-sm-offset-4">';
1010
foreach ($userdata as $ukey => $value)
1111
{
12-
echo '<spawn class="btn btn-danger">'.$ukey.'</spawn>:'.$value;
12+
echo '<spawn class="btn btn-danger">'.$ukey.'</spawn>:'.$value.br();
1313
}
1414
echo '</div></div>';
15+
echo form_fieldset_close() . PHP_EOL;
16+
17+
echo 'Click here to test checksession on other module/controller: '.anchor('Indexother','<spawn class="btn btn-danger">Go to indexother</spawn>');
18+
echo br();
19+
echo 'Click here to test checksession on same controller but textfunct method: '.anchor('Indexhome/testfunct','<spawn class="btn btn-danger">testfunc method</spawn>');
20+
echo br();
1521
echo anchor('Indexauth/auth/logout','<spawn class="btn btn-danger">Logout</spawn>');
1622

17-
echo form_fieldset_close() . PHP_EOL;
1823
?>

0 commit comments

Comments
 (0)