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

Hello,


On a website where the user can log in.
One week the session open to expire is secure? ($config['sess_expiration'] = 604800)

Thanks.
Reply
#2

No, it should be a few hours at most; implement a "remember me" cookie for longer times.
Reply
#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
#4

(This post was last modified: 01-13-2016, 09:46 AM by meow.)

I cant remember where I learned it, but I use:

PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Myclass extends CI_Controller
{
    private 
$logged_in

then in the construct
PHP Code:
$this->logged_in = ($this->session->userdata('signed_in')) ? TRUE FALSE

So, as soon as user is logged in, I set a sessiondatapiece signed_in = 1
Reply
#5

But I'd like to verify if exist cookie when open the site. On any page of the site.

Thanks.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB