Welcome Guest, Not a member yet? Register   Sign In
One week the session open to expire is secure
#3

(This post was last modified: 01-13-2016, 08:18 AM by edica.)

When user enter the site should verify if cookie exists. See code below. There is another way better?

library class:

class Autologin {

protected $CI;

    public function __construct()
    {
        $this->CI =& get_instance();
        if (!$this->CI->session->userdata('logged_in')) { $this->auto_login(); }    <==== This is cool?
    }

    public function auto_login()
    {
        $this->CI->load->helper('cookie');
        $this->CI->load->library('session');

        $user_name = get_cookie('user_name');
        $user_email = get_cookie('user_email');

        if (!empty($user_email) && !empty($user_name)) {

            $user_data = array(
                'nome' => $user_name,
                'email' => $user_email,
            );

            $this->CI->session->set_userdata('logged_in',$user_data);
            $arr = $this->CI->session->all_userdata();
        }
    }


}
Reply


Messages In This Thread
RE: One week the session open to expire is secure - by edica - 01-13-2016, 08:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB