Welcome Guest, Not a member yet? Register   Sign In
Store username and password in session is it safe?
#3

[eluser]Kency[/eluser]
Thank for you reply CroNix

Because users login into admin panel will have or haven't role to see some functions, therefore that i want to get the password in the admin controller ( because login controller get password from user when he/she type it into textfield) and i have to check if user management in his group is 1, he can view this function, otherwise he can't

and 1 more question is how to pass username through many controller?

i use global variable but i think it not a good way to pass username through every controller

because my view like:

Code:
<?php $this->load->view("admin/includes/header");?>

<?php $this->load->view("admin/includes/leftmenu");?>

<?php $this->load->view("admin/includes/navmenu");?>

<?php $this->load->view("admin/".$main_content);?>

<?php $this->load->view("admin/includes/footer");?>

just only $main_content is dynamic, but when controller A pass parameter $main_content into this class like:

Code:
$data['content'] = 'Content ABC';
$this->load->view('template',$data);

but when i do it, it will reload header - footer and navigtion menu.

if i use session to store admin each controller i must do the same thing to pass username into view (username is displayed in navigation menu class - it is a html template)

example:

when i pass username into view on controller site.php

Code:
$username;// global variable

class Admin extends CI_Controller {


    public function __construct()
    {
        parent::__construct();

        if(is_logged_in() != true){
            /* check user login or not if not redirect into error page*/
            redirect(base_url('admin/login/errorlogin'));
        } else{
                 $session_data = is_logged_in();
                 $uname = $session_data['username'];
                 $GLOBALS['username'] = $uname;

        }

    }



    public function loadGUI($content){
        $data['main_content'] = "main";
        $data['username'] =  $GLOBALS['username'] ;
        $this->load->view("admin/includes/template",$data);
    }

my code snippet like above, you can see, in a controller above when i want to show username of user i must create global variable and do the same thing like controller above, it take may times.

and as i mention before, user Tom login into admin panel, but Tom can't not see user management. and user Sisi login into admin with role admin she can see whatever.

How to handle it , just pass 1 time but use many time?

thank you very much


Messages In This Thread
Store username and password in session is it safe? - by El Forum - 05-03-2012, 09:23 AM
Store username and password in session is it safe? - by El Forum - 05-03-2012, 09:50 AM
Store username and password in session is it safe? - by El Forum - 05-03-2012, 01:13 PM
Store username and password in session is it safe? - by El Forum - 05-03-2012, 01:34 PM
Store username and password in session is it safe? - by El Forum - 05-03-2012, 01:56 PM
Store username and password in session is it safe? - by El Forum - 05-03-2012, 10:03 PM
Store username and password in session is it safe? - by El Forum - 05-03-2012, 11:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB