Welcome Guest, Not a member yet? Register   Sign In
How to use session
#1

Hello

I have the last stable version of codeigniter and try to use session. If someone is not authentified, I display the identification form. Something very classic but...

My session works but only in the same page as soon as I change the page I loose it.

Here is an example
public function __construct()
{
    parent::__construct();
    $this->load->helper('url');
    $this->load->library('session');
    $this->load->database();
    $this->load->model('user_model');    
    //session_start();
             
    // on controle ici si une session utilisateur existe

        echo "session ok!!!".$this->session->userapp;
    $userapp = $this->session->userdata('userapp');

    //$userapp = $_SESSION['userapp1'];
    echo 'userapp '.$userapp;
    /*if($userapp == false || $userapp  ==  NULL || empty($userapp )){
$url = site_url('/login');
    echo '<br/><a href='.$url.'>'.$url.'</a>';
quit();
        //redirect('login','refresh');
        }*/
    }

...


it is always empty

and here is my login
function logincheck(){
    echo '<br/>session.. '.$this->session->userapp;
    $uscode = $this->input->post('identifiant');
    $erreur = 0;
    if ($data['r'] = $this->user_model->get_1userpercode($uscode)){
        if ($data['r']['uspass'] == md5($this->input->post('mdp'))) {
            $this->session->set_userdata('userapp', $data['r']['uscode']);
            //$_SESSION['userapp1'] = $data['r']['uscode'];
            echo "session ok!".$this->session->userdata('userapp');
            echo '<br/>session '.$this->session->userapp;
        }
        else
        {
            $erreur = 1;
        }    
    }
    else
    {
        $erreur = 1;
    }

On this login page, my session is ok I can see the user

What should I do to use session


On the manual I read

Open the application/config/config.php file with a text editor and set your base URL. If you intend to use encryption or sessions, set your encryption key.

what does that means ? I want to use session what shall I do ? shall I set an encryption key ? How ?
Reply


Messages In This Thread
How to use session - by kris - 06-08-2017, 06:54 AM
RE: How to use session - by kris - 06-09-2017, 12:23 AM
RE: How to use session - by kris - 06-09-2017, 01:10 AM
RE: How to use session - by Krycek - 06-09-2017, 01:43 AM
RE: How to use session - by Krycek - 06-12-2017, 01:42 AM
RE: How to use session - by kris - 06-09-2017, 01:45 AM
RE: How to use session - by InsiteFX - 06-09-2017, 04:31 AM
RE: How to use session - by kris - 06-09-2017, 04:53 AM
RE: How to use session - by Krycek - 06-09-2017, 04:59 AM
RE: How to use session - by kris - 06-11-2017, 05:32 AM
RE: How to use session - by gabrielinbuon - 06-11-2017, 12:44 PM
RE: How to use session - by Diederik - 06-11-2017, 02:01 PM
RE: How to use session - by InsiteFX - 06-12-2017, 03:57 AM
RE: How to use session - by kris - 06-14-2017, 06:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB