Keep client logged in http and https

2

I am finalizing my virtual store developed in codeigniter 3 and database mysql is working perfectly. Now I want to start configuring the digital certificate.

My problem is this: when I go to the environment https soon on the site all right, but when I go back to http it does not keep the client logged in. How can I solve this? Or is it anyway and would have to do something else?

From now on thank you very much to all the friends.

    
asked by anonymous 08.09.2015 / 14:33

2 answers

1

Good morning, my friend!

Adding this to the top of the "index" of each page HTTPS is automatically triggered, let's say, go from HTTP to HTTPS

<?
{
$new_url = "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("Location: $new_url");
exit;
}


ForceHTTPS() //para chamar a função

?>

Any questions are available! Note: My website is functional.

    
08.09.2015 / 15:04
1

Store all user data in $_SESSION . It will be available in any instance, regardless of encryption.

Upload the Session Library or autoload .

I already made a helper that received the data of FORM after validated like this:

if( ! function_exists('session_set_userdata')){
    function session_set_userdata(){
        $ci = & get_instance();
        $controller = $ci->router->fetch_class();
        $method = $ci->router->fetch_method();
        unset($_SESSION['user']);
        $data = [
            'session' => sha1(date('H:m:i')),
            'logged' => TRUE,
            'captcha' => $ci->input->post('captcha'),
            'method' => $method,
            'controller' => $controller,
            'email' => $ci->input->post('email'),
            'ip_address' => $ci->input->ip_address(),
            'user_agent' => $ci->input->user_agent()
        ];
        $_SESSION['user'] = $data;
    }
}
    
06.01.2017 / 21:12