Welcome Guest, Not a member yet? Register   Sign In
return all user data from CI session
#1

[eluser]jayfox911[/eluser]
I added this function to the session.php in CI system libraries folder to return the session array.
Code:
/**
     * Fetch all items form  the session array
     *
     * @access    public
     * @param    string
     * @return    array
     */    
    function alluserdata()
    {
        return $this->userdata;
    }
use it in the controller:
Code:
$this->load->library('session');
$this->data['session'] = $this->session->alluserdata();
$this->load->view('login_view', $this->data);
view:
Code:
print '<br/>Username: '. $session['username'];
#2

[eluser]Crimp[/eluser]
Code:
// --------------------------------------------------------------------
    
    /**
     * Fetch all session data
     *
     * @access    public
     * @return    mixed
     */    
    function all_userdata()
    {
        return ( ! isset($this->userdata)) ? FALSE : $this->userdata;
    }
#3

[eluser]jayfox911[/eluser]
[quote author="Crimp" date="1193783211"]
Code:
// --------------------------------------------------------------------
    
    /**
     * Fetch all session data
     *
     * @access    public
     * @return    mixed
     */    
    function all_userdata()
    {
        return ( ! isset($this->userdata)) ? FALSE : $this->userdata;
    }
[/quote]

did you write this or is that part of CI.

with mine I did not have the isset because the session array is alway populated during creation however the user can unset the session array.

Thanks
#4

[eluser]ELRafael[/eluser]
this is a question or just an improved?
#5

[eluser]jayfox911[/eluser]
improvement, i was searching for a way to get thesession array and could not find a good answer.

so i made a new function to do what i wanted.
#6

[eluser]Derek Allard[/eluser]
The session class in the SVN has the code Crimp copied. You can grab a copy now and use it if you want. It also has flash vars, and there is some additional work being done on it.
#7

[eluser]Crimp[/eluser]
Sorry, I thought it was simply an oversight by the author. I have used the SVN versions for updates for so long, I forget what came before...




Theme © iAndrew 2016 - Forum software by © MyBB