CodeIgniter Forums
[split] Community Auth - session variables? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: [split] Community Auth - session variables? (/showthread.php?tid=67650)



[split] Community Auth - session variables? - oscar1925 - 03-20-2017

How to add session variables so that i can retrieve it in any of my views?


RE: [split] Community Auth - session variables? - skunkbad - 03-20-2017

What do you mean by session variables? The session ID? The value of "auth_identifiers"?


RE: [split] Community Auth - session variables? - oscar1925 - 02-13-2018

Thanks for the reply Guro,

i wish to add some session variables like username, name etc. ....

Code:
__ci_last_regenerate|i:1518568247;auth_identifiers|s:83:"a:2:{s:7:"user_id";s:10:"1307276232";s:10:"login_time";s:19:"2018-02-14 01:30:47";}";

aside from user_id and login_time how may i able to add some data ?


RE: [split] Community Auth - session variables? - oscar1925 - 02-13-2018

what i did to remedy this is.....

i add some codes to Auth_model.php (line 40 to 50 up) to be a able to add some data to the session table...  Undecided


Code:
// User table query
        $query = $this->db->select( $selected_columns )
            ->from( $this->db_table('user_table') )
            ->where( 'LOWER( username ) =', strtolower( $user_string ) )
            ->or_where( 'LOWER( email ) =', strtolower( $user_string ) )
            ->limit(1)
            ->get();

        if( $query->num_rows() == 1 )
        {
            $row = $query->row_array();

            /*my code 1925*/
            $this->session->set_userdata('usr_id', $row['user_id'] ); // add nako
            $this->session->set_userdata('campusid', $row['userscampus'] ); // add nako
            $this->load->model('signinm'); // i add this model
            $query = $this->signinm->does_user_exist($row['user_id']);
            if ($query->num_rows() == 1) { /*mother loop asking if naa ba nakita nga account sa database*/
                        foreach ($query->result() as $rows) {
            //$name = concat($rows->usr_fname,' ',$rows->usr_mname,' ',$rows->usr_lname,' ',$rows->namexcode);
            $this->session->set_userdata('campusname', $rows->campusname );
            $this->session->set_userdata('sy', $rows->sy );
            $this->session->set_userdata('sem', $rows->sem );
            $this->session->set_userdata('sycode', $rows->sycode );
            $this->session->set_userdata('semcode', $rows->semcode );
            $this->session->set_userdata('schoolname', $rows->schoolname );
            $this->session->set_userdata('schoolid', $rows->schoolid );
            $this->session->set_userdata('name', $rows->usersfn.' '.$rows->usersmn.' '.$rows->usersln.' '.$rows->nxdisplay ); // add nako // add nako
            }
            /*1925*/

bad coding... may i know how to add session data in simple way? Shy


RE: [split] Community Auth - session variables? - skunkbad - 02-14-2018

I tell you what ... I hate using sessions for anything I don't have to, and if your user is logged in, you can get all that stuff from the database. There's no reason to put it in the session. If you do NEED the session to have that data, then it's kind of up to you as the developer to make decisions on how to integrate that into your app. Advice on this kind of thing is beyond the scope of Community Auth support.