Welcome Guest, Not a member yet? Register   Sign In
extend session class
#1

[eluser]labidi4[/eluser]
is to possible to add another column to the database table where sessions data are saved ?, for example i want to add column named user_type where i can save the type of the connected user(costumer, manager...) so it will be easy for me to get only the connected managers , thanks
#2

[eluser]InsiteFX[/eluser]
Just store it in the session user_data
#3

[eluser]labidi4[/eluser]
i thought that it will be better if i run a query select * from session_data where user_type = manageres than selecting all the connected people and then unserialize the user_data and check if he is a manager or not !!! i hope you understand what i mean , thanks
#4

[eluser]InsiteFX[/eluser]
You can add the column to the table but you will need to handle it or extend the session class.
#5

[eluser]labidi4[/eluser]
that's what i'am looking for : how to extend the session class
i already added the column to the table and i tried to extend the session class but it doesn't work :/
I would really appreciate it if you or someone else could give me an idea how to do it Smile
#6

[eluser]InsiteFX[/eluser]
Add to ./application/libraries/MY_Session.php
Code:
class MY_Session extends CI_Session {

    private $CI;  // in case you need the CI super object.

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

        $this->CI = get_instance();
    }

} // End of Class.

Another Example:
Code:
class MY_Session extends CI_Session {

// --------------------------------------------------------------------

/**
  * sess_update()
  *
     * Do not update an existing session on ajax or xajax calls
     *
     * @access    public
     * @return    void
     */
    public function sess_update()
{
  $_ci = get_instance();

  if ( ! $_ci->input->is_ajax_request())
  {
   parent::sess_update();
  }
    }

// --------------------------------------------------------------------

/**
  * sess_destroy()
  *
     * Clear's out the user_data array on sess::destroy.
     *
     * @access    public
     * @return    void
     */
public function sess_destroy()
{
  $this->userdata = array();

  parent::sess_destroy();
}

} // End of Class.





Theme © iAndrew 2016 - Forum software by © MyBB